-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle passing a function pointer ref through a ref returning method #49526
Conversation
@dotnet/roslyn-compiler for review. |
@@ -2292,6 +2292,29 @@ internal static bool CheckRefEscape(SyntaxNode node, BoundExpression expr, uint | |||
diagnostics, | |||
isRefEscape: true); | |||
|
|||
case BoundKind.FunctionPointerInvocation: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
case BoundKind.FunctionPointerInvocation: [](start = 16, length = 41)
Minor: I would put this case next to ```case BoundKind.Call:``
Note to self: change the title to "Handle passing a ref returned from a function pointer invocation from a ref returning method" before merging. |
@@ -10677,6 +10677,178 @@ .maxstack 4 | |||
"); | |||
} | |||
|
|||
[Fact, WorkItem(49315, "https://github.com/dotnet/roslyn/issues/49315")] | |||
public void ReturnByRefFromRefReturningMethod() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReturnByRefFromRefReturningMethod [](start = 20, length = 33)
It looks like we are only testing ref pass-through for at return position. Were other possible ref pass-through constructs/positions not affected? Consider adding some tests for them too: assignment to ref local, passing to a byref parameter, ref ternary, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (iteration 2), with tests suggestion.
@dotnet/roslyn-compiler for a second review. I'll work on adding Aleksey's test suggestions, but it would be good to address any other feedback at the same time. |
@dotnet/roslyn-compiler for another review please. |
@dotnet/roslyn-compiler for a second review please. |
Fixes #49315.