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

Fix overload resolution regression around params parameters #73373

Merged
merged 3 commits into from
May 9, 2024

Conversation

AlekseyTs
Copy link
Contributor

Fixes #73346.

@AlekseyTs AlekseyTs requested review from 333fred and RikkiGibson May 7, 2024 19:26
@AlekseyTs AlekseyTs requested a review from a team as a code owner May 7, 2024 19:26
@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label May 7, 2024
@@ -2261,11 +2245,9 @@ private static ParameterSymbol GetParameter(int argIndex, MemberAnalysisResult r
continue;
}

var parameter1 = GetParameter(i, m1.Result, m1Original);
uninst1.Add(GetParameterType(parameter1, m1.Result, m1Original.Length));
uninst1.Add(getParameterTypeAndRefKind(i, m1.Result, m1DefinitionParameters, m1.Result.DefinitionParamsElementTypeOpt, out _));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefinitionParamsElementTypeOpt

This is where the actual fix is


var parameter2 = GetParameter(i, m2.Result, m2Original);
uninst2.Add(GetParameterType(parameter2, m2.Result, m2Original.Length));
uninst2.Add(getParameterTypeAndRefKind(i, m2.Result, m2DefinitionParameters, m2.Result.DefinitionParamsElementTypeOpt, out _));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

DefinitionParamsElementTypeOpt

This is where the actual fix is

public class Foo
{
public void Method<S>(params Func<Bar, S>[] projections) => Console.Write(1);
public void Method<S>(params Func<Bar, Wrapper<S>>[] projections) => Console.Write(2);
Copy link
Member

@cston cston May 7, 2024

Choose a reason for hiding this comment

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

Method

Please test a constructor as well. #Resolved

@AlekseyTs AlekseyTs requested a review from cston May 7, 2024 21:27
@AlekseyTs
Copy link
Contributor Author

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

1 similar comment
@AlekseyTs
Copy link
Contributor Author

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

@RikkiGibson RikkiGibson self-assigned this May 8, 2024
{
public class C
{
public void Method<S>(params Func<Bar, S>[] projections) => Console.Write(1);
Copy link
Contributor

@RikkiGibson RikkiGibson May 8, 2024

Choose a reason for hiding this comment

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

Consider also testing a "params collections" scenario such as params IEnumerable<Func<Bar, S>> versus params IEnumerable<Func<Bar, Wrapper<S>>> #Resolved

@AlekseyTs AlekseyTs enabled auto-merge (squash) May 9, 2024 01:30
@AlekseyTs AlekseyTs merged commit c23414e into dotnet:main May 9, 2024
24 checks passed
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone May 9, 2024
@danielcweber
Copy link

We'd please need some kind of workaround because the bug has found its way into 8.0.300, the stable Visual studio, the preview of Visual Studio anyway, uninstalling 8.0.300 won't do, uninstalling 9.x-preview won't do, fixating 8.0.204 in global.json and disallowing rollforward won't do.

@jjonescz
Copy link
Member

jjonescz commented May 22, 2024

As a temporary workaround you could try installing Microsoft.Net.Compilers.Toolset package which will force use of a specific compiler version. If you are not relying on new features, you could try using some older version from NuGet; or you can use the latest version from AzDo feed (but you need to add that feed to a NuGet.config). Don't forget to uninstall this package once the fix is released in the SDK, because it's not supported as a long-term solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Feature - ParamsCollections 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.

Overload resolution ambiguity introduced by SDK 8.0.300-preview.24203.14
6 participants