Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2dd951d

Browse files
committed
Address@amos402's comment on raising branch.
1 parent536c1bd commit2dd951d

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
elseif(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+
returnmatch;
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=newArrayList();
707714
for(varv=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-
elseif(!isOperator&&!paramsArray)
733+
elseif(!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
elseif(pynargs>clrnargs&&clrnargs>0&&
740740
Attribute.IsDefined(parameters[clrnargs-1],typeof(ParamArrayAttribute)))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp