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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10627,7 +10627,7 @@ bool satisfiesConstraintChecks(MethodSymbol method)
parameters.SelectAsArray(p => p.ExplicitDefaultConstantValue) :
default;

var hasParams = OverloadResolution.IsValidParams(this, methodSymbol);
var hasParams = OverloadResolution.IsValidParams(this, methodSymbol, out _);

Debug.Assert(ContainingMemberOrLambda is { });
Debug.Assert(parameterRefKinds.IsDefault || parameterRefKinds.Length == parameterTypes.Length);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ private void ReportDynamicInvocationWarnings(SyntaxNode syntax, BoundMethodGroup
private bool IsAmbiguousDynamicParamsArgument<TMethodOrPropertySymbol>(ArrayBuilder<BoundExpression> arguments, MemberResolutionResult<TMethodOrPropertySymbol> candidate, out SyntaxNode argumentSyntax)
where TMethodOrPropertySymbol : Symbol
{
if (OverloadResolution.IsValidParams(this, candidate.LeastOverriddenMember) &&
if (OverloadResolution.IsValidParams(this, candidate.LeastOverriddenMember, out _) &&
candidate.Result.Kind == MemberResolutionKind.ApplicableInNormalForm)
{
var parameters = candidate.Member.GetParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ private init

public readonly int BadParameter;
public readonly MemberResolutionKind Kind;
public readonly TypeWithAnnotations DefinitionParamsElementTypeOpt;
public readonly TypeWithAnnotations ParamsElementTypeOpt;

/// <summary>
Expand All @@ -121,11 +122,14 @@ private MemberAnalysisResult(
int missingParameter = -1,
bool hasAnyRefOmittedArgument = false,
ImmutableArray<TypeParameterDiagnosticInfo> constraintFailureDiagnosticsOpt = default,
TypeWithAnnotations definitionParamsElementTypeOpt = default,
TypeWithAnnotations paramsElementTypeOpt = default)
{
Debug.Assert(kind != MemberResolutionKind.ApplicableInExpandedForm || definitionParamsElementTypeOpt.HasType);
Debug.Assert(kind != MemberResolutionKind.ApplicableInExpandedForm || paramsElementTypeOpt.HasType);

this.Kind = kind;
this.DefinitionParamsElementTypeOpt = definitionParamsElementTypeOpt;
this.ParamsElementTypeOpt = paramsElementTypeOpt;
this.BadArgumentsOpt = badArgumentsOpt;
this.ArgsToParamsOpt = argsToParamsOpt;
Expand Down Expand Up @@ -314,7 +318,7 @@ public static MemberAnalysisResult UnsupportedMetadata()
return new MemberAnalysisResult(MemberResolutionKind.UnsupportedMetadata);
}

public static MemberAnalysisResult BadArgumentConversions(ImmutableArray<int> argsToParamsOpt, BitVector badArguments, ImmutableArray<Conversion> conversions, TypeWithAnnotations paramsElementTypeOpt)
public static MemberAnalysisResult BadArgumentConversions(ImmutableArray<int> argsToParamsOpt, BitVector badArguments, ImmutableArray<Conversion> conversions, TypeWithAnnotations definitionParamsElementTypeOpt, TypeWithAnnotations paramsElementTypeOpt)
{
Debug.Assert(conversions.Length != 0);
Debug.Assert(badArguments.TrueBits().Any());
Expand All @@ -323,6 +327,7 @@ public static MemberAnalysisResult BadArgumentConversions(ImmutableArray<int> ar
badArguments,
argsToParamsOpt,
conversions,
definitionParamsElementTypeOpt: definitionParamsElementTypeOpt,
paramsElementTypeOpt: paramsElementTypeOpt);
}

Expand Down Expand Up @@ -373,9 +378,11 @@ public static MemberAnalysisResult NormalForm(ImmutableArray<int> argsToParamsOp
return new MemberAnalysisResult(MemberResolutionKind.ApplicableInNormalForm, BitVector.Null, argsToParamsOpt, conversions, hasAnyRefOmittedArgument: hasAnyRefOmittedArgument);
}

public static MemberAnalysisResult ExpandedForm(ImmutableArray<int> argsToParamsOpt, ImmutableArray<Conversion> conversions, bool hasAnyRefOmittedArgument, TypeWithAnnotations paramsElementType)
public static MemberAnalysisResult ExpandedForm(ImmutableArray<int> argsToParamsOpt, ImmutableArray<Conversion> conversions, bool hasAnyRefOmittedArgument, TypeWithAnnotations definitionParamsElementType, TypeWithAnnotations paramsElementType)
{
return new MemberAnalysisResult(MemberResolutionKind.ApplicableInExpandedForm, BitVector.Null, argsToParamsOpt, conversions, hasAnyRefOmittedArgument: hasAnyRefOmittedArgument, paramsElementTypeOpt: paramsElementType);
return new MemberAnalysisResult(
MemberResolutionKind.ApplicableInExpandedForm, BitVector.Null, argsToParamsOpt, conversions,
hasAnyRefOmittedArgument: hasAnyRefOmittedArgument, definitionParamsElementTypeOpt: definitionParamsElementType, paramsElementTypeOpt: paramsElementType);
}

public static MemberAnalysisResult Worse()
Expand Down
Loading