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

Overload resolution was ignoring HasTypeArgumentInferredFromFunctionType for calls in expanded form #57633

Merged
merged 1 commit into from
Nov 9, 2021

Conversation

cston
Copy link
Member

@cston cston commented Nov 8, 2021

For calls to generic overloads with a params parameter, overload resolution was ignoring whether type inference relied on function types, so the "better function member" was not preferring calls with no function types.

Fixes #57627.

new MemberResolutionResult<TMember>(
result.Member,
result.LeastOverriddenMember,
result.WithResult(
Copy link
Member Author

Choose a reason for hiding this comment

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

result.WithResult

The fix is this change to retain result.HasTypeInferredFromFunctionType.

@cston cston marked this pull request as ready for review November 9, 2021 07:42
@cston cston requested a review from a team as a code owner November 9, 2021 07:42
@@ -3465,7 +3460,7 @@ internal EffectiveParameters(ImmutableArray<TypeWithAnnotations> types, Immutabl
ref useSiteInfo);
if (typeArguments.IsDefault)
{
return new MemberResolutionResult<TMember>(member, leastOverriddenMember, inferenceError);
return new MemberResolutionResult<TMember>(member, leastOverriddenMember, inferenceError, hasTypeArgumentInferredFromFunctionType: false);
Copy link
Contributor

Choose a reason for hiding this comment

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

hasTypeArgumentInferredFromFunctionType: false

Why not simply pass hasTypeArgumentsInferredFromFunctionType?

Copy link
Member Author

@cston cston Nov 9, 2021

Choose a reason for hiding this comment

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

We could although typeArguments.IsDefault is returned for error conditions, and hasTypeArgumentsInferredFromFunctionType == false.

Copy link
Contributor

@AlekseyTs AlekseyTs left a comment

Choose a reason for hiding this comment

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

LGTM (commit 1)

@cston cston merged commit c9aa8f0 into dotnet:main Nov 9, 2021
@cston cston deleted the 57627 branch November 9, 2021 18:30
@ghost ghost added this to the Next milestone Nov 9, 2021
@cston cston modified the milestones: Next, 17.1.P2 Nov 9, 2021
cston added a commit to cston/roslyn that referenced this pull request Nov 12, 2021
cston added a commit that referenced this pull request Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET 6.100 The call is ambiguous between the following methods or properties breaking change
3 participants