1
0
mirror of https://github.com/golang/go synced 2024-09-24 03:10:16 -06:00

[dev.typeparams] cmd/compile: use new converter functions rather than methods (fix build)

Change-Id: I4dcaca1f2e67ee32f70c22b2efa586232ca519bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/293958
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This commit is contained in:
Robert Griesemer 2021-02-18 15:09:38 -08:00
parent 20050a15fe
commit a789be7814
3 changed files with 12 additions and 7 deletions

View File

@ -237,15 +237,15 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
}
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

View File

@ -55,11 +55,11 @@ func (s *Selection) Recv() Type { return s.recv }
// 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

View File

@ -971,3 +971,8 @@ func asTypeParam(t Type) *TypeParam {
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) }