Skip to content

Commit 90cd7d3

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

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/runtime/methodbinder.cs

Lines changed: 12 additions & 12 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-
// every parameter past 'positionalArgumentCount' must have either
702-
// 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)
705701
match = true;
702+
// operator methods will have 2 CLR args but only one Python arg,
703+
// since 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+
}
710+
// every parameter past 'positionalArgumentCount' must have either
711+
// a corresponding keyword arg or a default param, unless the method
712+
// 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy