@@ -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