Skip to content

Conversation

@cston
Copy link
Contributor

@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
Contributor 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
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
Contributor 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