}
recvType2Base := recvType2
if wantPtr {
- recvType2Base = recvType2.Pointer().Elem()
+ recvType2Base = types2.AsPointer(recvType2).Elem()
}
- if len(recvType2Base.Named().TParams()) > 0 {
+ if len(types2.AsNamed(recvType2Base).TParams()) > 0 {
// recvType2 is the original generic type that is
// instantiated for this method call.
// selinfo.Recv() is the instantiated type
recvType2 = recvType2Base
// method is the generic method associated with the gen type
- method := g.obj(recvType2.Named().Method(last))
+ method := g.obj(types2.AsNamed(recvType2).Method(last))
n = ir.NewSelectorExpr(pos, ir.OCALLPART, x, method.Sym())
n.(*ir.SelectorExpr).Selection = types.NewField(pos, method.Sym(), method.Type())
n.(*ir.SelectorExpr).Selection.Nname = method
// TODO(gri): fix this bug.
func (s *Selection) TArgs() []Type {
r := s.recv
- if r.Pointer() != nil {
- r = r.Pointer().Elem()
+ if p := asPointer(r); p != nil {
+ r = p.Elem()
}
- if r.Named() != nil {
- return r.Named().TArgs()
+ if n := asNamed(r); n != nil {
+ return n.TArgs()
}
// The base type (after skipping any pointer) must be a Named type. The
// bug is that sometimes it can be an instance type (which is supposed to
u, _ := under(t).(*TypeParam)
return u
}
+
+// Exported for the compiler.
+
+func AsPointer(t Type) *Pointer { return asPointer(t) }
+func AsNamed(t Type) *Named { return asNamed(t) }