]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/go/types/lookup.go
go/types, types2: introduce _Alias type node
[gostls13.git] / src / go / types / lookup.go
index d96dd86e5eb0d866658ca0e7b7fb521c5507303a..e6ad72843743ab2a856006e36bedf34904cb1fbf 100644 (file)
@@ -56,7 +56,7 @@ func LookupFieldOrMethod(T Type, addressable bool, pkg *Package, name string) (o
        // Thus, if we have a named pointer type, proceed with the underlying
        // pointer type but discard the result if it is a method since we would
        // not have found it for T (see also go.dev/issue/8590).
-       if t, _ := T.(*Named); t != nil {
+       if t := asNamed(T); t != nil {
                if p, _ := t.Underlying().(*Pointer); p != nil {
                        obj, index, indirect = lookupFieldOrMethodImpl(p, false, pkg, name, false)
                        if _, ok := obj.(*Func); ok {
@@ -140,7 +140,7 @@ func lookupFieldOrMethodImpl(T Type, addressable bool, pkg *Package, name string
 
                        // If we have a named type, we may have associated methods.
                        // Look for those first.
-                       if named, _ := typ.(*Named); named != nil {
+                       if named := asNamed(typ); named != nil {
                                if alt := seen.lookup(named); alt != nil {
                                        // We have seen this type before, at a more shallow depth
                                        // (note that multiples of this type at the current depth
@@ -529,7 +529,7 @@ func (check *Checker) newAssertableTo(pos token.Pos, V, T Type, cause *string) b
 // with an underlying pointer type!) and returns its base and true.
 // Otherwise it returns (typ, false).
 func deref(typ Type) (Type, bool) {
-       if p, _ := typ.(*Pointer); p != nil {
+       if p, _ := _Unalias(typ).(*Pointer); p != nil {
                // p.base should never be nil, but be conservative
                if p.base == nil {
                        if debug {