Skip to content
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
4 changes: 3 additions & 1 deletion src/Compilers/CSharp/Portable/Binder/Binder_Operators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2714,7 +2714,9 @@ static void appendViableMethods(LookupResult lookupResult, int parameterCount, A

static bool isViable(MethodSymbol method, int parameterCount)
{
return method.ParameterCount == parameterCount;
Debug.Assert(parameterCount is 0 or 1);
return method.ParameterCount == parameterCount && method.ReturnsVoid && !method.IsVararg &&
(parameterCount == 0 || method.Parameters[0].RefKind is RefKind.None or RefKind.In);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1173,8 +1173,6 @@ private bool HasValidOperatorParameterRefKinds()

private bool IsValidInstanceUserDefinedOperatorSignature(int parameterCount)
{
// PROTOTYPE: Cover negative scenarios

if (!this.ReturnsVoid || this.IsGenericMethod || this.IsVararg || this.ParameterCount != parameterCount || this.IsParams())
{
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ protected SourceUserDefinedOperatorSymbolBase(
}
else
{
// PROTOTYPE: Cover explicit implementation scenarios

Binder.CheckFeatureAvailability(syntax, MessageID.IDS_FeatureUserDefinedCompoundAssignmentOperators, diagnostics, ((OperatorDeclarationSyntax)syntax).OperatorToken.GetLocation());

if (parameterCount is not (0 or 2))
Expand All @@ -78,7 +76,6 @@ protected SourceUserDefinedOperatorSymbolBase(
}
else if (isCompoundAssignment)
{
// PROTOTYPE: Cover explicit implementation scenarios
Binder.CheckFeatureAvailability(syntax, MessageID.IDS_FeatureUserDefinedCompoundAssignmentOperators, diagnostics, ((OperatorDeclarationSyntax)syntax).OperatorToken.GetLocation());
}

Expand Down Expand Up @@ -566,7 +563,6 @@ private void CheckOperatorSignatures(BindingDiagnosticBag diagnostics)
diagnostics.Add(ErrorCode.ERR_OperatorMustReturnVoid, this.GetFirstLocation());
}

// PROTOTYPE: Test/handle scenarios with ref modifiers on the parameter
break;

default:
Expand Down
Loading