@@ -8,9 +8,13 @@ import (
8
8
"fmt"
9
9
"go/types"
10
10
"reflect"
11
+
12
+ "golang.org/x/tools/internal/aliases"
11
13
)
12
14
13
15
func (d * differ ) checkCompatible (otn * types.TypeName , old , new types.Type ) {
16
+ old = aliases .Unalias (old )
17
+ new = aliases .Unalias (new )
14
18
switch old := old .(type ) {
15
19
case * types.Interface :
16
20
if new , ok := new .(* types.Interface ); ok {
@@ -268,7 +272,7 @@ func (d *differ) checkCompatibleDefined(otn *types.TypeName, old *types.Named, n
268
272
return
269
273
}
270
274
// Interface method sets are checked in checkCompatibleInterface.
271
- if _ , ok := old . Underlying ().( * types. Interface ); ok {
275
+ if types . IsInterface ( old ) {
272
276
return
273
277
}
274
278
@@ -287,7 +291,7 @@ func (d *differ) checkMethodSet(otn *types.TypeName, oldt, newt types.Type, addc
287
291
oldMethodSet := exportedMethods (oldt )
288
292
newMethodSet := exportedMethods (newt )
289
293
msname := otn .Name ()
290
- if _ , ok := oldt .(* types.Pointer ); ok {
294
+ if _ , ok := aliases . Unalias ( oldt ) .(* types.Pointer ); ok {
291
295
msname = "*" + msname
292
296
}
293
297
for name , oldMethod := range oldMethodSet {
@@ -349,9 +353,9 @@ func receiverType(method types.Object) types.Type {
349
353
}
350
354
351
355
func receiverNamedType (method types.Object ) * types.Named {
352
- switch t := receiverType (method ).(type ) {
356
+ switch t := aliases . Unalias ( receiverType (method ) ).(type ) {
353
357
case * types.Pointer :
354
- return t .Elem ().(* types.Named )
358
+ return aliases . Unalias ( t .Elem () ).(* types.Named )
355
359
case * types.Named :
356
360
return t
357
361
default :
@@ -360,6 +364,6 @@ func receiverNamedType(method types.Object) *types.Named {
360
364
}
361
365
362
366
func hasPointerReceiver (method types.Object ) bool {
363
- _ , ok := receiverType (method ).(* types.Pointer )
367
+ _ , ok := aliases . Unalias ( receiverType (method ) ).(* types.Pointer )
364
368
return ok
365
369
}
0 commit comments