mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00: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:
parent
20050a15fe
commit
a789be7814
3 changed files with 12 additions and 7 deletions
|
|
@ -237,15 +237,15 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
|
||||||
}
|
}
|
||||||
recvType2Base := recvType2
|
recvType2Base := recvType2
|
||||||
if wantPtr {
|
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
|
// recvType2 is the original generic type that is
|
||||||
// instantiated for this method call.
|
// instantiated for this method call.
|
||||||
// selinfo.Recv() is the instantiated type
|
// selinfo.Recv() is the instantiated type
|
||||||
recvType2 = recvType2Base
|
recvType2 = recvType2Base
|
||||||
// method is the generic method associated with the gen type
|
// 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.NewSelectorExpr(pos, ir.OCALLPART, x, method.Sym())
|
||||||
n.(*ir.SelectorExpr).Selection = types.NewField(pos, method.Sym(), method.Type())
|
n.(*ir.SelectorExpr).Selection = types.NewField(pos, method.Sym(), method.Type())
|
||||||
n.(*ir.SelectorExpr).Selection.Nname = method
|
n.(*ir.SelectorExpr).Selection.Nname = method
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,11 @@ func (s *Selection) Recv() Type { return s.recv }
|
||||||
// TODO(gri): fix this bug.
|
// TODO(gri): fix this bug.
|
||||||
func (s *Selection) TArgs() []Type {
|
func (s *Selection) TArgs() []Type {
|
||||||
r := s.recv
|
r := s.recv
|
||||||
if r.Pointer() != nil {
|
if p := asPointer(r); p != nil {
|
||||||
r = r.Pointer().Elem()
|
r = p.Elem()
|
||||||
}
|
}
|
||||||
if r.Named() != nil {
|
if n := asNamed(r); n != nil {
|
||||||
return r.Named().TArgs()
|
return n.TArgs()
|
||||||
}
|
}
|
||||||
// The base type (after skipping any pointer) must be a Named type. The
|
// 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
|
// bug is that sometimes it can be an instance type (which is supposed to
|
||||||
|
|
|
||||||
|
|
@ -971,3 +971,8 @@ func asTypeParam(t Type) *TypeParam {
|
||||||
u, _ := under(t).(*TypeParam)
|
u, _ := under(t).(*TypeParam)
|
||||||
return u
|
return u
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Exported for the compiler.
|
||||||
|
|
||||||
|
func AsPointer(t Type) *Pointer { return asPointer(t) }
|
||||||
|
func AsNamed(t Type) *Named { return asNamed(t) }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue