@@ -305,20 +305,22 @@ func (l *instanceLookup) add(inst *Named) {
305
305
// present in V have matching types (e.g., for a type assertion x.(T) where
306
306
// x is of interface type V).
307
307
func MissingMethod (V Type , T * Interface , static bool ) (method * Func , wrongType bool ) {
308
- m , alt := (* Checker )(nil ).missingMethod (V , T , static )
308
+ m , alt := (* Checker )(nil ).missingMethod (V , T , static , Identical )
309
309
// Only report a wrong type if the alternative method has the same name as m.
310
310
return m , alt != nil && alt .name == m .name // alt != nil implies m != nil
311
311
}
312
312
313
- // missingMethod is like MissingMethod but accepts a *Checker as receiver.
313
+ // missingMethod is like MissingMethod but accepts a *Checker as receiver
314
+ // and comparator equivalent for type comparison.
314
315
// The receiver may be nil if missingMethod is invoked through an exported
315
316
// API call (such as MissingMethod), i.e., when all methods have been type-
316
317
// checked.
318
+ // The comparator is used to compare signatures.
317
319
//
318
320
// If a method is missing on T but is found on *T, or if a method is found
319
321
// on T when looked up with case-folding, this alternative method is returned
320
322
// as the second result.
321
- func (check * Checker ) missingMethod (V Type , T * Interface , static bool ) (method , alt * Func ) {
323
+ func (check * Checker ) missingMethod (V Type , T * Interface , static bool , equivalent func ( x , y Type ) bool ) (method , alt * Func ) {
322
324
if T .NumMethods () == 0 {
323
325
return
324
326
}
@@ -336,7 +338,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
336
338
return m , nil
337
339
}
338
340
339
- if ! Identical (f .typ , m .typ ) {
341
+ if ! equivalent (f .typ , m .typ ) {
340
342
return m , f
341
343
}
342
344
}
@@ -370,7 +372,7 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
370
372
check .objDecl (f , nil )
371
373
}
372
374
373
- if ! found || ! Identical (f .typ , m .typ ) {
375
+ if ! found || ! equivalent (f .typ , m .typ ) {
374
376
return m , f
375
377
}
376
378
}
@@ -467,7 +469,7 @@ func (check *Checker) assertableTo(V *Interface, T Type) (method, wrongType *Fun
467
469
return
468
470
}
469
471
// TODO(gri) fix this for generalized interfaces
470
- return check .missingMethod (T , V , false )
472
+ return check .missingMethod (T , V , false , Identical )
471
473
}
472
474
473
475
// newAssertableTo reports whether a value of type V can be asserted to have type T.
0 commit comments