use types.Unalias() throughout in preparation for gotypesalias=1
related to https://github.com/golang/open2opaque/issues/11
PiperOrigin-RevId: 720589086
Change-Id: I7ec7f12886e9a3fb99c02f7247c7437ec17c3581
diff --git a/internal/fix/assign.go b/internal/fix/assign.go
index 9c766e3..f3dd2f5 100644
--- a/internal/fix/assign.go
+++ b/internal/fix/assign.go
@@ -304,7 +304,7 @@
func isNeverNilSliceExpr(c *cursor, e dst.Expr) bool {
// Is this a string to byte conversion?
if ce, ok := e.(*dst.CallExpr); ok && len(ce.Args) == 1 {
- if bt, ok := c.typeOf(ce.Args[0]).(*types.Basic); ok && bt.Kind() == types.String {
+ if bt, ok := types.Unalias(c.typeOf(ce.Args[0])).(*types.Basic); ok && bt.Kind() == types.String {
if at, ok := ce.Fun.(*dst.ArrayType); ok {
if id, ok := at.Elt.(*dst.Ident); ok && id.Name == "byte" {
return true
@@ -313,7 +313,7 @@
}
}
if _, ok := e.(*dst.CompositeLit); ok {
- if _, ok := c.typeOf(e).(*types.Slice); ok {
+ if _, ok := types.Unalias(c.typeOf(e)).(*types.Slice); ok {
return true
}
}
@@ -362,7 +362,7 @@
c.Logf("rewriting Enum() call")
if t := c.typeOfOrNil(enumVal); t != nil {
- if pt, ok := t.(*types.Pointer); ok {
+ if pt, ok := types.Unalias(t).(*types.Pointer); ok {
enumVal = &dst.StarExpr{X: enumVal}
c.setType(enumVal, pt.Elem())
}
@@ -446,8 +446,8 @@
c.Logf("rewriting assignment with rhs Expr")
f := c.objectOf(lhsSel.Sel).(*types.Var)
isProto2 := !isProto3Field(c.typeOf(lhsSel.X), f.Name())
- if slice, ok := f.Type().(*types.Slice); ok && isProto2 {
- if basic, ok := slice.Elem().(*types.Basic); ok && basic.Kind() == types.Uint8 {
+ if slice, ok := types.Unalias(f.Type()).(*types.Slice); ok && isProto2 {
+ if basic, ok := types.Unalias(slice.Elem()).(*types.Basic); ok && basic.Kind() == types.Uint8 {
if isNeverNilSliceExpr(c, rhs) {
stmt := c.expr2stmt(sel2call(c, "Set", lhsSel, rhs, decs), lhsSel)
return stmt, true
@@ -755,11 +755,11 @@
}
t := c.typeOf(call.Args[0])
- if t, ok := t.(*types.Basic); ok {
+ if t, ok := types.Unalias(t).(*types.Basic); ok {
return scalarTypeZeroExpr(c, t), true
}
- if _, ok := t.(*types.Named); !ok {
+ if _, ok := types.Unalias(t).(*types.Named); !ok {
return nil, false
}
@@ -955,7 +955,7 @@
return ue.X
}
out := &dst.StarExpr{X: expr}
- c.setType(out, c.underlyingTypeOf(expr).(*types.Pointer).Elem())
+ c.setType(out, types.Unalias(c.underlyingTypeOf(expr)).(*types.Pointer).Elem())
return out
}
diff --git a/internal/fix/build.go b/internal/fix/build.go
index 19688ba..0363547 100644
--- a/internal/fix/build.go
+++ b/internal/fix/build.go
@@ -160,7 +160,7 @@
}
// Skip over fields that are not oneof.
- if _, ok := c.underlyingTypeOf(kv.Key).(*types.Interface); !ok {
+ if _, ok := types.Unalias(c.underlyingTypeOf(kv.Key)).(*types.Interface); !ok {
c.Logf("skipping none oneof field", e)
continue
}
@@ -239,7 +239,7 @@
if fieldValue == nil {
updates = append(updates, func() {
kv.Key.(*dst.Ident).Name = fieldName // Rename the key to field name from the oneof wrapper.
- kv.Value = c.newProtoHelperCall(nil, fieldType.(*types.Basic))
+ kv.Value = c.newProtoHelperCall(nil, types.Unalias(fieldType).(*types.Basic))
})
c.Logf("generated RHS for field %v", fieldName)
continue
diff --git a/internal/fix/conflictingname.go b/internal/fix/conflictingname.go
index c0cae08..bf34d2f 100644
--- a/internal/fix/conflictingname.go
+++ b/internal/fix/conflictingname.go
@@ -11,10 +11,10 @@
func fixConflictingNames(t types.Type, prefix, name string) string {
if prefix != "" {
- if pt, ok := t.(*types.Pointer); ok {
+ if pt, ok := types.Unalias(t).(*types.Pointer); ok {
t = pt.Elem()
}
- st := t.(*types.Named).Underlying().(*types.Struct)
+ st := types.Unalias(t).(*types.Named).Underlying().(*types.Struct)
for i := 0; i < st.NumFields(); i++ {
if st.Field(i).Name() == prefix+name {
return "_" + name
diff --git a/internal/fix/fixcursor.go b/internal/fix/fixcursor.go
index 0269d76..9abc0e5 100644
--- a/internal/fix/fixcursor.go
+++ b/internal/fix/fixcursor.go
@@ -317,10 +317,10 @@
}
elem := c.typeOf(lit)
- if ptr, ok := elem.(*types.Pointer); ok {
+ if ptr, ok := types.Unalias(elem).(*types.Pointer); ok {
elem = ptr.Elem()
}
- if named, ok := elem.(*types.Named); ok {
+ if named, ok := types.Unalias(elem).(*types.Named); ok {
obj := named.Obj()
typeName := obj.Pkg().Path() + "." + obj.Name()
c.Logf("always use builders for %q? %v", typeName, c.builderTypes[typeName])
@@ -449,10 +449,10 @@
func (c *cursor) selectorForProtoMessageType(t types.Type) *dst.SelectorExpr {
// Get to the elementary type (pb.M2) if this is a pointer type (*pb.M2).
elem := t
- if ptr, ok := elem.(*types.Pointer); ok {
+ if ptr, ok := types.Unalias(elem).(*types.Pointer); ok {
elem = ptr.Elem()
}
- named, ok := elem.(*types.Named)
+ named, ok := types.Unalias(elem).(*types.Named)
if !ok {
log.Fatalf("BUG: proto message unexpectedly not a named type (but %T)?!", elem)
}
@@ -518,16 +518,16 @@
}
func isInterfaceVararg(t types.Type) bool {
- vararg, ok := t.(*types.Slice)
+ vararg, ok := types.Unalias(t).(*types.Slice)
if !ok {
return false
}
- _, ok = vararg.Elem().(*types.Interface)
+ _, ok = types.Unalias(vararg.Elem()).(*types.Interface)
return ok
}
func isString(t types.Type) bool {
- b, ok := t.(*types.Basic)
+ b, ok := types.Unalias(t).(*types.Basic)
return ok && b.Kind() == types.String
}
@@ -549,7 +549,7 @@
return true
}
}
- sig, ok := c.typeOf(call.Fun).(*types.Signature)
+ sig, ok := types.Unalias(c.typeOf(call.Fun)).(*types.Signature)
if !ok {
return false
}
@@ -588,7 +588,7 @@
func (c *cursor) messageTypeName(t types.Type) (name string, ok bool) {
name = t.String()
- if nt, ok := t.(*types.Named); ok && isPtr(nt.Underlying()) {
+ if nt, ok := types.Unalias(t).(*types.Named); ok && isPtr(nt.Underlying()) {
// A non-pointer named type whose underlying type is a pointer can be
// neither proto struct nor pointer to a proto struct. If we were to
// return "true" for such type, it was most likely "type T *pb.M" for some
@@ -596,11 +596,11 @@
return "", false
}
- if p, ok := t.(*types.Pointer); ok {
+ if p, ok := types.Unalias(t).(*types.Pointer); ok {
t = p.Elem()
}
- nt, ok := t.(*types.Named)
+ nt, ok := types.Unalias(t).(*types.Named)
if !ok {
return "", false
}
@@ -672,22 +672,22 @@
}
f := c.objectOf(sel.Sel).(*types.Var)
// Handle messages (either proto2 or proto3) and proto2 enums.
- if p, ok := f.Type().(*types.Pointer); ok {
- if _, ok := p.Elem().(*types.Named); ok {
+ if p, ok := types.Unalias(f.Type()).(*types.Pointer); ok {
+ if _, ok := types.Unalias(p.Elem()).(*types.Named); ok {
return true
}
}
// Handle non-enum proto2 scalars.
isProto2 := !isProto3Field(c.typeOf(sel.X), f.Name())
if isProto2 {
- switch ft := f.Type().(type) {
+ switch ft := types.Unalias(f.Type()).(type) {
case *types.Pointer:
- if _, ok := ft.Elem().(*types.Basic); ok {
+ if _, ok := types.Unalias(ft.Elem()).(*types.Basic); ok {
return true
}
case *types.Slice:
// Use Clear for bytes field, but not other repeated fields.
- if basic, ok := ft.Elem().(*types.Basic); ok && basic.Kind() == types.Uint8 {
+ if basic, ok := types.Unalias(ft.Elem()).(*types.Basic); ok && basic.Kind() == types.Uint8 {
return true
}
}
@@ -728,7 +728,7 @@
// Exactly one of expr or t should be non-nil. expr can be nil only if t is *types.Basic
func (c *cursor) newProtoHelperCall(expr dst.Expr, t types.Type) dst.Expr {
- if _, ok := t.(*types.Basic); expr == nil && !ok {
+ if _, ok := types.Unalias(t).(*types.Basic); expr == nil && !ok {
panic(fmt.Sprintf("t must be *types.Basic if expr is nil, but it is %T", t))
}
if t == nil && expr == nil {
@@ -739,7 +739,7 @@
}
// Enums are represented as named types in generated files.
- if t, ok := t.(*types.Named); ok {
+ if t, ok := types.Unalias(t).(*types.Named); ok {
fun := &dst.SelectorExpr{
X: expr,
Sel: &dst.Ident{Name: "Enum"},
@@ -755,7 +755,7 @@
c.setType(out, types.NewPointer(t))
return out
}
- bt := t.(*types.Basic)
+ bt := types.Unalias(t).(*types.Basic)
if expr == nil {
expr = scalarTypeZeroExpr(c, bt)
}
@@ -822,7 +822,7 @@
if strings.HasPrefix(sel.Sel.Name, "XXX_") {
return nil, false
}
- if _, ok := c.underlyingTypeOf(sel.Sel).(*types.Signature); ok {
+ if _, ok := types.Unalias(c.underlyingTypeOf(sel.Sel)).(*types.Signature); ok {
return nil, false
}
return sel, true
@@ -846,7 +846,7 @@
if strings.HasPrefix(sel.Sel.Name, "XXX_") {
return nil, nil, false
}
- if sig, ok := c.underlyingTypeOf(sel.Sel).(*types.Signature); ok {
+ if sig, ok := types.Unalias(c.underlyingTypeOf(sel.Sel)).(*types.Signature); ok {
if strings.HasPrefix(sel.Sel.Name, "Has") ||
strings.HasPrefix(sel.Sel.Name, "Clear") ||
strings.HasPrefix(sel.Sel.Name, "Set") ||
diff --git a/internal/fix/get.go b/internal/fix/get.go
index f635c5a..f27eb00 100644
--- a/internal/fix/get.go
+++ b/internal/fix/get.go
@@ -267,7 +267,7 @@
func funcLiteralForHas(c *cursor, n dst.Expr, field *dst.SelectorExpr) dst.Node {
nodeElemType := c.typeOf(n)
- if ptr, ok := nodeElemType.(*types.Pointer); ok {
+ if ptr, ok := types.Unalias(nodeElemType).(*types.Pointer); ok {
nodeElemType = ptr.Elem()
}
msgType := c.typeOf(field.X)
@@ -285,7 +285,7 @@
}
var retElemType dst.Expr = &dst.Ident{Name: nodeElemType.String()}
- if named, ok := nodeElemType.(*types.Named); ok {
+ if named, ok := types.Unalias(nodeElemType).(*types.Named); ok {
pkgID := &dst.Ident{Name: c.imports.name(named.Obj().Pkg().Path())}
c.setType(pkgID, types.Typ[types.Invalid])
pkgSel := &dst.Ident{Name: named.Obj().Name()}
diff --git a/internal/fix/has.go b/internal/fix/has.go
index 1809a33..80a935c 100644
--- a/internal/fix/has.go
+++ b/internal/fix/has.go
@@ -130,9 +130,9 @@
if !ok {
return true
}
- if s, ok := c.typeOf(field).(*types.Slice); ok {
+ if s, ok := types.Unalias(c.typeOf(field)).(*types.Slice); ok {
// use "len" for proto3 bytes fields.
- if bt, ok := s.Elem().(*types.Basic); ok && bt.Kind() == types.Byte {
+ if bt, ok := types.Unalias(s.Elem()).(*types.Basic); ok && bt.Kind() == types.Byte {
// m.F == nil => len(m.GetF()) == 0
// m.F != nil => len(m.GetF()) != 0
var getVal dst.Expr = field
diff --git a/internal/fix/hasneeded.go b/internal/fix/hasneeded.go
index 4bc8e9e..5d9ce51 100644
--- a/internal/fix/hasneeded.go
+++ b/internal/fix/hasneeded.go
@@ -71,7 +71,7 @@
return false
}
fieldType := c.typeOf(sel)
- if pt, ok := fieldType.(*types.Pointer); ok {
+ if pt, ok := types.Unalias(fieldType).(*types.Pointer); ok {
fieldType = pt.Elem()
}
// If expr a binary condition we check if it is a comparison against nil
@@ -167,7 +167,7 @@
// isScalarTypeZeroExpr returns true if e is a zero value for t
func isScalarTypeZeroExpr(c *cursor, t types.Type, e dst.Expr) bool {
- if _, ok := t.(*types.Basic); !isBytes(t) && !isEnum(t) && !ok {
+ if _, ok := types.Unalias(t).(*types.Basic); !isBytes(t) && !isEnum(t) && !ok {
return false
}
zeroExpr := scalarTypeZeroExpr(c, t)
diff --git a/internal/fix/naming.go b/internal/fix/naming.go
index f6717fb..f1bf53c 100644
--- a/internal/fix/naming.go
+++ b/internal/fix/naming.go
@@ -15,10 +15,10 @@
func helperVarNameForType(t types.Type) string {
// Get to the elementary type (pb.M2) if this is a pointer type (*pb.M2).
elem := t
- if ptr, ok := elem.(*types.Pointer); ok {
+ if ptr, ok := types.Unalias(elem).(*types.Pointer); ok {
elem = ptr.Elem()
}
- named, ok := elem.(*types.Named)
+ named, ok := types.Unalias(elem).(*types.Named)
if !ok {
log.Fatalf("BUG: proto message unexpectedly not a named type (but %T)?!", elem)
}
diff --git a/internal/fix/oneof.go b/internal/fix/oneof.go
index 6236d6c..89815d1 100644
--- a/internal/fix/oneof.go
+++ b/internal/fix/oneof.go
@@ -54,7 +54,7 @@
// First we need to collect an exhaustive list of alternatives. We do this
// by collecting all wrapper types for the given field that are defined in
// the generated proto package.
- nt, ok := t.(*types.Named)
+ nt, ok := types.Unalias(t).(*types.Named)
if !ok {
c.Logf("ignoring oneof of type %T (looking for *types.Named)", c.Node())
return nil, false
@@ -105,7 +105,7 @@
if !idt.Exported() {
continue
}
- nt, ok := idt.Type().(*types.Named)
+ nt, ok := types.Unalias(idt.Type()).(*types.Named)
if !ok {
continue
}
@@ -337,7 +337,7 @@
if !ok {
return oneofWrapperSelector(c, x)
}
- s, ok := c.underlyingTypeOf(clit).(*types.Struct)
+ s, ok := types.Unalias(c.underlyingTypeOf(clit)).(*types.Struct)
if !ok || s.NumFields() != 1 {
return oneofWrapperSelector(c, x)
}
@@ -381,7 +381,7 @@
id := &dst.Ident{
Name: "byte",
}
- c.setType(id, valType.(*types.Slice).Elem())
+ c.setType(id, types.Unalias(valType).(*types.Slice).Elem())
typ := &dst.ArrayType{
Elt: id,
}
@@ -399,7 +399,7 @@
return s.Field(0).Name(), valType, valueOrDefault(c, "ValueOrDefaultBytes", val), decs, true
}
isMsgOneof := false
- if ptr, ok := valType.(*types.Pointer); ok && (protodetecttypes.Type{T: ptr.Elem()}.IsMessage()) {
+ if ptr, ok := types.Unalias(valType).(*types.Pointer); ok && (protodetecttypes.Type{T: ptr.Elem()}.IsMessage()) {
isMsgOneof = true
}
if isMsgOneof && val != nil && !isNeverNilExpr(c, val) {
@@ -444,10 +444,10 @@
c.numUnsafeRewritesByReason[MaybeOneofChange]++
t := c.underlyingTypeOf(x)
- if p, ok := t.(*types.Pointer); ok {
+ if p, ok := types.Unalias(t).(*types.Pointer); ok {
t = p.Elem().Underlying()
}
- s := t.(*types.Struct)
+ s := types.Unalias(t).(*types.Struct)
val := &dst.SelectorExpr{
X: x,
Sel: &dst.Ident{
@@ -457,7 +457,7 @@
valType := s.Field(0).Type()
c.setType(val.Sel, valType)
c.setType(val, s.Field(0).Type())
- if ptr, ok := valType.(*types.Pointer); ok && (protodetecttypes.Type{T: ptr.Elem()}.IsMessage()) {
+ if ptr, ok := types.Unalias(valType).(*types.Pointer); ok && (protodetecttypes.Type{T: ptr.Elem()}.IsMessage()) {
return s.Field(0).Name(), valType, valueOrDefault(c, "ValueOrDefault", val), decs, true
}
return s.Field(0).Name(), s.Field(0).Type(), val, decs, true
diff --git a/internal/fix/oneofswitch.go b/internal/fix/oneofswitch.go
index 471d51e..a953f13 100644
--- a/internal/fix/oneofswitch.go
+++ b/internal/fix/oneofswitch.go
@@ -550,11 +550,11 @@
if !strings.HasPrefix(name, "Which") {
panic(fmt.Sprintf("whichOneofSignature called with %q; must have 'Which' prefix", name))
}
- ptr, ok := t.(*types.Pointer)
+ ptr, ok := types.Unalias(t).(*types.Pointer)
if !ok {
return nil
}
- typ, ok := ptr.Elem().(*types.Named)
+ typ, ok := types.Unalias(ptr.Elem()).(*types.Named)
if !ok {
return nil
}
diff --git a/internal/fix/outputparam.go b/internal/fix/outputparam.go
index 16af42d..e20240f 100644
--- a/internal/fix/outputparam.go
+++ b/internal/fix/outputparam.go
@@ -145,7 +145,7 @@
}
T := c.typeOf(dstT.(dst.Expr))
- ptr, ok := T.(*types.Pointer)
+ ptr, ok := types.Unalias(T).(*types.Pointer)
if !ok {
c.Logf("parameter %T is not a proto message", param.Type)
return false
diff --git a/internal/fix/rules.go b/internal/fix/rules.go
index 85a5fcf..7be0299 100644
--- a/internal/fix/rules.go
+++ b/internal/fix/rules.go
@@ -146,7 +146,7 @@
return out
}
- bt, ok := t.(*types.Basic)
+ bt, ok := types.Unalias(t).(*types.Basic)
if !ok {
panic(fmt.Sprintf("scalarTypeZeroExpr called with %T", t))
}
@@ -235,21 +235,21 @@
}
func isBasic(t types.Type) bool {
- _, ok := t.(*types.Basic)
+ _, ok := types.Unalias(t).(*types.Basic)
return ok
}
func isBytes(t types.Type) bool {
- s, ok := t.(*types.Slice)
+ s, ok := types.Unalias(t).(*types.Slice)
if !ok {
return false
}
- elem, ok := s.Elem().(*types.Basic)
+ elem, ok := types.Unalias(s.Elem()).(*types.Basic)
return ok && elem.Kind() == types.Byte
}
func isEnum(t types.Type) bool {
- n, ok := t.(*types.Named)
+ n, ok := types.Unalias(t).(*types.Named)
if !ok {
return false
}
@@ -277,10 +277,10 @@
func isOneofWrapper(c *cursor, x dst.Expr) bool {
t := c.underlyingTypeOf(x)
- if p, ok := t.(*types.Pointer); ok {
+ if p, ok := types.Unalias(t).(*types.Pointer); ok {
t = p.Elem().Underlying()
}
- s, ok := t.(*types.Struct)
+ s, ok := types.Unalias(t).(*types.Struct)
if !ok || s.NumFields() != 1 {
return false
}
@@ -328,7 +328,7 @@
t := c.underlyingTypeOf(sel.Sel)
if isPtrToBasic(t) {
- t = t.(*types.Pointer).Elem()
+ t = types.Unalias(t).(*types.Pointer).Elem()
}
var pkg *types.Package
if use := c.objectOf(sel.Sel); use != nil {
diff --git a/internal/fix/stats.go b/internal/fix/stats.go
index dc1e7a5..a2a7346 100644
--- a/internal/fix/stats.go
+++ b/internal/fix/stats.go
@@ -280,7 +280,7 @@
if c.shouldTrackType(t) {
return t, true
}
- switch t := t.(type) {
+ switch t := types.Unalias(t).(type) {
case *types.Tuple:
for i := 0; i < t.Len(); i++ {
if t, ok := c.shouldLogCompositeType(t.At(i).Type(), followPointers); ok {
@@ -353,7 +353,7 @@
}
func typeName(t types.Type) string {
- if iface, ok := t.(*types.Interface); ok && iface.Empty() {
+ if iface, ok := types.Unalias(t).(*types.Interface); ok && iface.Empty() {
return "interface{}"
}
return t.String()
@@ -636,7 +636,7 @@
// "f(*m)"
// "f(g())" where g() returns at least one protocol buffer message
- ft, ok := c.typeOf(call.Fun).(*types.Signature)
+ ft, ok := types.Unalias(c.typeOf(call.Fun)).(*types.Signature)
if !ok {
return out
}
@@ -646,7 +646,7 @@
if arg0t == nil {
return logSiloed(c, out, call.Args[0], parent)
}
- if tuple, ok := arg0t.(*types.Tuple); ok {
+ if tuple, ok := types.Unalias(arg0t).(*types.Tuple); ok {
// Handle "f(g())"-style calls where g() returns a tuple of results.
for i := 0; i < tuple.Len(); i++ {
argTypes = append(argTypes, tuple.At(i).Type())
@@ -668,7 +668,7 @@
if i < ft.Params().Len()-1 {
t = ft.Params().At(i).Type()
} else {
- t = ft.Params().At(ft.Params().Len() - 1).Type().(*types.Slice).Elem()
+ t = types.Unalias(ft.Params().At(ft.Params().Len() - 1).Type()).(*types.Slice).Elem()
}
} else {
t = ft.Params().At(i).Type()
@@ -739,12 +739,12 @@
continue
}
- if _, ok := rhst.(*types.Tuple); !ok {
+ if _, ok := types.Unalias(rhst).(*types.Tuple); !ok {
continue
}
- out = logConversion(c, out, nil, rhst.(*types.Tuple).At(i).Type(), lhst, as, parent, conversion)
- out = logShallowCopy(c, out, nil, rhst.(*types.Tuple).At(i).Type(), as, parent, shallowCopy)
+ out = logConversion(c, out, nil, types.Unalias(rhst).(*types.Tuple).At(i).Type(), lhst, as, parent, conversion)
+ out = logShallowCopy(c, out, nil, types.Unalias(rhst).(*types.Tuple).At(i).Type(), as, parent, shallowCopy)
}
}
return out
@@ -817,7 +817,7 @@
Type: spb.ShallowCopy_COMPOSITE_LITERAL_ELEMENT,
},
}
- switch t := c.underlyingTypeOf(lit).(type) {
+ switch t := types.Unalias(c.underlyingTypeOf(lit)).(type) {
case *types.Pointer: // e.g. []*struct{m *pb.M}{{m2}}
if kv, ok := e.(*dst.KeyValueExpr); ok {
t := c.typeOfOrNil(kv.Key)
@@ -925,7 +925,7 @@
if underlying == nil {
return logSiloed(c, nil, send, parent)
}
- dst := underlying.(*types.Chan).Elem()
+ dst := types.Unalias(underlying).(*types.Chan).Elem()
out := logConversion(c, nil, send.Value, nil, dst, send, parent, &spb.Use{
Type: spb.Use_CONVERSION,
Conversion: &spb.Conversion{
@@ -962,13 +962,13 @@
if pt == nil {
return logSiloed(c, nil, ret, parent)
}
- sig = pt.(*types.Signature)
+ sig = types.Unalias(pt).(*types.Signature)
case *dst.FuncLit:
pt := c.typeOfOrNil(p)
if pt == nil {
return logSiloed(c, nil, ret, parent)
}
- sig = pt.(*types.Signature)
+ sig = types.Unalias(pt).(*types.Signature)
default:
panic(fmt.Sprintf("invalid parent function type %T; must be *dst.FuncDecl or *dst.FuncLit", p))
}
@@ -991,7 +991,7 @@
if rt0 == nil {
return logSiloed(c, nil, ret.Results[0], parent)
}
- rt := rt0.(*types.Tuple)
+ rt := types.Unalias(rt0).(*types.Tuple)
if a, b := sig.Results().Len(), rt.Len(); a != b {
panic(fmt.Sprintf("number of function return value types (%d) doesn't match the number of returned values as a tuple (%d)", a, b))
}
@@ -1144,7 +1144,7 @@
if p, ok := t.Underlying().(*types.Pointer); ok {
t = p.Elem()
}
- nt, ok := t.(*types.Named)
+ nt, ok := types.Unalias(t).(*types.Named)
if !ok {
return false
}
@@ -1190,7 +1190,7 @@
name := strings.TrimPrefix(t.String(), "*")
t = t.Underlying()
- if p, ok := t.(*types.Pointer); ok {
+ if p, ok := types.Unalias(t).(*types.Pointer); ok {
t = p.Elem()
}
if !(protodetecttypes.Type{T: t}.IsMessage()) {