-
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
Add support for calling local functions with dynamic args #10710
Conversation
var args = resolution.AnalyzedArguments.Arguments; | ||
var localFunction = validResult.Member; | ||
var parameters = localFunction.Parameters; | ||
var methodResult = validResult.Result; |
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.
Pleas replace all vars with types.
@AlekseyTs I tried a slightly different approach to looking for dynamic arguments to a |
@@ -76,6 +76,33 @@ void VerifyDiagnostics(string source, CSharpCompilationOptions options, params D | |||
} | |||
|
|||
[Fact] |
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.
Add [CompilerTrait(CompilerFeature.Dynamic)]
👍 |
// normal and expanded form i.e., there is exactly one dynamic | ||
// argument to a params parameter | ||
if (OverloadResolution.IsValidParams(localFunction) && | ||
args.Count == parameters.Length) |
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.
I don't think the second condition should be met. Consider this for example:
static void Test4(int x = 0, params int[] y)
{
dynamic z = x;
Test4(y: z);
}
Should probably add a unit-test for similar scenario.
Only exception is params parameters, tracked by dotnet#10708. Fixes dotnet#10389
// because there is an ambiguity between an array target | ||
// and the params element target. See | ||
// https://github.com/dotnet/roslyn/issues/10708 | ||
Debug.Assert(resolution.OverloadResolutionResult.Succeeded); |
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.
I was wondering how you handle "call by name" part when you do not know the mangled name of the method.
I see how :-) It is not supported for now.
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.
Correct -- that'll be a completely different implementation, so I didn't want to mix these things together in the same PR.
LGTM |
e0ec4be
to
0d13966
Compare
Should the test be also marked as LocalFunctions tests? |
LGTM |
@AlekseyTs the test class is marked as a |
@jaredpar Thanks. |
…tnet#10710)" This reverts commit 1548892.
…args (dotnet#10710)"" This reverts commit 5777c60.
Only exception is params parameters, tracked by #10708.
Fixes #10389
@jaredpar @VSadov @dotnet/roslyn-compiler Please review.