Skip to content

Commit 2dd951d

Browse files
committed
Address @amos402's comment on raising branch.
1 parent 536c1bd commit 2dd951d

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/runtime/methodbinder.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -698,11 +698,18 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters,
698698
}
699699
else if (pynargs < clrnargs && (!paramsArray || pynargs == clrnargs - 1))
700700
{
701+
match = true;
702+
// operator methods will have 2 CLR args but only one Python arg, since
703+
// Python operator methods are bound
704+
if (isOperator)
705+
{
706+
// return early since a C# operator method cannot have
707+
// keyword args, default args, or params arrays (exclusive cases)
708+
return match;
709+
}
701710
// every parameter past 'positionalArgumentCount' must have either
702711
// a corresponding keyword argument or a default parameter, unless
703-
// the method is an operator or accepts a params array (which cannot
704-
// have a default value)
705-
match = true;
712+
// the method accepts a params array (which cannot have a default value).
706713
defaultArgList = new ArrayList();
707714
for (var v = pynargs; v < clrnargs; v++)
708715
{
@@ -723,18 +730,11 @@ static bool MatchesArgumentCount(int pynargs, ParameterInfo[] parameters,
723730
defaultArgList.Add(parameters[v].GetDefaultValue());
724731
defaultsNeeded++;
725732
}
726-
else if (!isOperator && !paramsArray)
733+
else if (!paramsArray)
727734
{
728-
// this is separate above because an operator method cannot have
729-
// keyword args, default args, or params arrays (exclusive cases)
730735
match = false;
731736
}
732737
}
733-
if (isOperator && defaultArgList.Count == 0)
734-
{
735-
// If no default arguments were provided for an operable object.
736-
defaultArgList = null;
737-
}
738738
}
739739
else if (pynargs > clrnargs && clrnargs > 0 &&
740740
Attribute.IsDefined(parameters[clrnargs - 1], typeof(ParamArrayAttribute)))

0 commit comments

Comments
 (0)