Skip to content
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

Statically bind invocations in presence of dynamic arguments only for local functions #73314

Merged
merged 8 commits into from
May 7, 2024

Conversation

AlekseyTs
Copy link
Contributor

@AlekseyTs AlekseyTs commented May 2, 2024

Fixes #72750.

This implements the latest LDM decision.
In order to make sure all artifacts of the previous fix (#72964) were removed, I reverted all implementation (but not test changes) from that PR by using 'git revert`. All cleanups/refactorings that are still relevant were manually ported back.

… local functions, extension methods or expanded non-array params cases.

Related to dotnet#72750.
This is an alternative limited approach for QB mode.
… `dynamic` arguments (dotnet#72964)"

This reverts compiler changes (tests changes are not reverted) made in commit 5a49045.
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 2, 2024
@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented May 2, 2024

            // (10,18): warning CS8624: Argument of type 'dynamic' cannot be used as an output of type 'int' for parameter 'x' in 'void C2.Deconstruct(out int x, out int y)' due to differences in the nullability of reference types.

This warning looks very strange. I'll open an issue to follow-up. #Closed


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/DynamicTests.cs:10599 in 8c74aca. [](commit_id = 8c74aca, deletion_comment = False)

@AlekseyTs AlekseyTs marked this pull request as ready for review May 3, 2024 02:29
@AlekseyTs AlekseyTs requested review from a team as code owners May 3, 2024 02:29
@AlekseyTs
Copy link
Contributor Author

@jcouv, @RikkiGibson, @dotnet/roslyn-compiler Please review

1 similar comment
@AlekseyTs
Copy link
Contributor Author

@jcouv, @RikkiGibson, @dotnet/roslyn-compiler Please review

@jcouv
Copy link
Member

jcouv commented May 3, 2024

Let's refresh dotnet/csharplang#8027 to capture the final design

@AlekseyTs
Copy link
Contributor Author

I am planning to do that. The change mostly will be as simple as moving the "Dynamic" section into the alternatives section.

addMethods = filterOutBadGenericMethods(addMethodBinder, syntax, methodGroup, analyzedArguments, resolution, finalApplicableCandidates, ref useSiteInfo);
result = !addMethods.IsEmpty;

if (!result)
{
diagnostics.Add(ErrorCode.ERR_CollectionExpressionMissingAdd, syntax, methodGroup.ReceiverOpt.Type);
}
else if (addMethods.Length == 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to tell whether we're keeping the correspondence with BindMethodGroupInvocation. What does this correspond to?

Copy link
Contributor Author

@AlekseyTs AlekseyTs May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to tell whether we're keeping the correspondence with BindMethodGroupInvocation. What does this correspond to?

It corresponds to the code at the end of bindInvocationExpressionContinued below. We are not going after exact match with BindMethodGroupInvocation because the argument that we are using is fake and we aways end up here when we have a single applicable candidate. Before the change we were ending up in bindInvocationExpressionContinued through tryEarlyBindSingleCandidateInvocationWithDynamicArgument.

Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM Thanks (iteration 8)

@AlekseyTs
Copy link
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For the second review

@jaredpar jaredpar added this to the 17.11 milestone May 6, 2024
@AlekseyTs
Copy link
Contributor Author

@RikkiGibson, @dotnet/roslyn-compiler For the second review

@RikkiGibson
Copy link
Contributor

Taking a look

@AlekseyTs AlekseyTs merged commit 93d19c2 into dotnet:main May 7, 2024
28 checks passed
@dotnet-policy-service dotnet-policy-service bot modified the milestones: 17.11, Next May 7, 2024
@AlekseyTs
Copy link
Contributor Author

AlekseyTs commented May 7, 2024

            // (10,18): warning CS8624: Argument of type 'dynamic' cannot be used as an output of type 'int' for parameter 'x' in 'void C2.Deconstruct(out int x, out int y)' due to differences in the nullability of reference types.

Opened #73374


In reply to: 2091415087


Refers to: src/Compilers/CSharp/Test/Semantic/Semantics/DynamicTests.cs:10599 in 8c74aca. [](commit_id = 8c74aca, deletion_comment = False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Language changes are breaking real-world use of dynamic
5 participants