@@ -508,7 +508,6 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
508508 int paramsArrayIndex = paramsArray ? pi . Length - 1 : - 1 ; // -1 indicates no paramsArray
509509 var usedImplicitConversion = false ;
510510 var kwargsMatched = 0 ;
511- var defaultsNeeded = 0 ;
512511
513512 // Conversion loop for each parameter
514513 for ( int paramIndex = 0 ; paramIndex < clrArgCount ; paramIndex ++ )
@@ -524,25 +523,24 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
524523 if ( paramIndex >= pyArgCount )
525524 {
526525 // All positional arguments have been used:
527- // Check our KWargs for this parameter
526+ // Check our KWargs for this parameter
528527 if ( hasNamedParam )
529528 {
530529 kwargsMatched ++ ;
531- if ( tempPyObject != null )
532- {
533- op = tempPyObject ;
534- }
530+ if ( tempPyObject != null )
531+ {
532+ op = tempPyObject ;
533+ }
535534 }
536535 else if ( parameter . IsOptional && ! ( hasNamedParam || ( paramsArray && paramIndex == paramsArrayIndex ) ) )
537- {
538- defaultsNeeded ++ ;
539- if ( defaultArgList != null )
540536 {
541- margs [ paramIndex ] = defaultArgList [ paramIndex - pyArgCount ] ;
542- }
537+ if ( defaultArgList != null )
538+ {
539+ margs [ paramIndex ] = defaultArgList [ paramIndex - pyArgCount ] ;
540+ }
543541
544- continue ;
545- }
542+ continue ;
543+ }
546544 }
547545
548546 NewReference tempObject = default ;
@@ -723,33 +721,33 @@ internal Binding Bind(BorrowedReference inst, BorrowedReference args, BorrowedRe
723721 var mi = bestMatch . Method ;
724722
725723 object ? target = null ;
726- if ( ! mi . IsStatic && inst != null )
727- {
728- //CLRObject co = (CLRObject)ManagedType.GetManagedObject(inst);
729- // InvalidCastException: Unable to cast object of type
730- // 'Python.Runtime.ClassObject' to type 'Python.Runtime.CLRObject'
731-
732- // Sanity check: this ensures a graceful exit if someone does
733- // something intentionally wrong like call a non-static method
734- // on the class rather than on an instance of the class.
735- // XXX maybe better to do this before all the other rigmarole.
724+ if ( ! mi . IsStatic && inst != null )
725+ {
726+ //CLRObject co = (CLRObject)ManagedType.GetManagedObject(inst);
727+ // InvalidCastException: Unable to cast object of type
728+ // 'Python.Runtime.ClassObject' to type 'Python.Runtime.CLRObject'
729+
730+ // Sanity check: this ensures a graceful exit if someone does
731+ // something intentionally wrong like call a non-static method
732+ // on the class rather than on an instance of the class.
733+ // XXX maybe better to do this before all the other rigmarole.
736734 if ( ManagedType . GetManagedObject ( inst ) is CLRObject co )
737735 {
738736 target = co . inst ;
739737 }
740738 else
741- {
739+ {
742740 Exceptions . SetError ( Exceptions . TypeError , "Invoked a non-static method with an invalid instance" ) ;
743- return null ;
744- }
741+ return null ;
745742 }
743+ }
746744
747- // If this match is generic we need to resolve it with our types.
748- // Store this generic match to be used if no others match
749- if ( mi . IsGenericMethod )
750- {
751- mi = ResolveGenericMethod ( ( MethodInfo ) mi , margs ) ;
752- }
745+ // If this match is generic we need to resolve it with our types.
746+ // Store this generic match to be used if no others match
747+ if ( mi . IsGenericMethod )
748+ {
749+ mi = ResolveGenericMethod ( ( MethodInfo ) mi , margs ) ;
750+ }
753751
754752 return new Binding ( mi , target , margs , outs ) ;
755753 }
0 commit comments