@@ -136,6 +136,7 @@ internal static MethodInfo MatchByTypeSig(MethodInfo[] msig,
136136 if ( pi . Length != plen ) {
137137 continue ;
138138 }
139+ bool matched = true ;
139140 for ( int n = 0 ; n < pi . Length ; n ++ ) {
140141 IntPtr p = Runtime . PyTuple_GetItem ( args , n ) ;
141142 if ( p == IntPtr . Zero ) {
@@ -145,15 +146,19 @@ internal static MethodInfo MatchByTypeSig(MethodInfo[] msig,
145146 ClassBase c = ManagedType . GetManagedObject ( p ) as ClassBase ;
146147 Type t = ( c != null ) ? c . type :
147148 Converter . GetTypeByAlias ( p ) ;
149+
148150 if ( t == null ) {
149151 break ;
150152 }
151153 if ( t != pi [ n ] . ParameterType ) {
154+ matched = false ;
152155 break ;
153156 }
154157 }
155- match = msig [ i ] ;
156- break ;
158+ if ( matched ) {
159+ match = msig [ i ] ;
160+ break ;
161+ }
157162 }
158163
159164 if ( free ) {
@@ -171,12 +176,26 @@ internal static MethodInfo MatchByTypeSig(MethodInfo[] msig,
171176 //====================================================================
172177
173178 internal Binding Bind ( IntPtr inst , IntPtr args , IntPtr kw ) {
179+ return this . Bind ( inst , args , kw , null ) ;
180+ }
181+
182+ internal Binding Bind ( IntPtr inst , IntPtr args , IntPtr kw ,
183+ MethodBase info ) {
174184 // loop to find match, return invoker w/ or /wo error
185+ MethodBase [ ] _methods = null ;
175186 int nargs = Runtime . PyTuple_Size ( args ) ;
176187 object arg ;
177188
178- MethodBase [ ] _methods = GetMethods ( ) ;
179-
189+ if ( info != null ) {
190+ _methods = ( MethodBase [ ] ) Array . CreateInstance (
191+ typeof ( MethodBase ) , 1
192+ ) ;
193+ _methods . SetValue ( info , 0 ) ;
194+ }
195+ else {
196+ _methods = GetMethods ( ) ;
197+ }
198+
180199 for ( int i = 0 ; i < _methods . Length ; i ++ ) {
181200 MethodBase mi = _methods [ i ] ;
182201 ParameterInfo [ ] pi = mi . GetParameters ( ) ;
@@ -220,9 +239,14 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw) {
220239 return null ;
221240 }
222241
223-
224242 internal virtual IntPtr Invoke ( IntPtr inst , IntPtr args , IntPtr kw ) {
225- Binding binding = this . Bind ( inst , args , kw ) ;
243+ return this . Invoke ( inst , args , kw , null ) ;
244+
245+ }
246+
247+ internal virtual IntPtr Invoke ( IntPtr inst , IntPtr args , IntPtr kw ,
248+ MethodBase info ) {
249+ Binding binding = this . Bind ( inst , args , kw , info ) ;
226250 Object result ;
227251
228252 if ( binding == null ) {
0 commit comments