cmd/compile: remove unneeded early transforms, with dictionary change

Now that we are computing the dictionary format on the instantiated
functions, we can remove the early transformation code that was needed
to create the implicit CONVIFACE nodes in the generic function.

Change-Id: I1695484e7d59bccbfb757994f3e40e84288759a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/349614
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Dan Scales 2021-09-12 12:21:48 -07:00
parent 59a9a035ff
commit cfa233d76b
5 changed files with 26 additions and 119 deletions

View file

@ -250,44 +250,6 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
// only be fully transformed once it has an instantiated type.
n := ir.NewSelectorExpr(pos, ir.OXDOT, x, typecheck.Lookup(expr.Sel.Value))
typed(g.typ(typ), n)
// Fill in n.Selection for a generic method reference or a bound
// interface method, even though we won't use it directly, since it
// is useful for analysis. Specifically do not fill in for fields or
// other interfaces methods (method call on an interface value), so
// n.Selection being non-nil means a method reference for a generic
// type or a method reference due to a bound.
obj2 := g.info.Selections[expr].Obj()
sig := types2.AsSignature(obj2.Type())
if sig == nil || sig.Recv() == nil {
return n
}
index := g.info.Selections[expr].Index()
last := index[len(index)-1]
// recvType is the receiver of the method being called. Because of the
// way methods are imported, g.obj(obj2) doesn't work across
// packages, so we have to lookup the method via the receiver type.
recvType := deref2(sig.Recv().Type())
if types2.AsInterface(recvType.Underlying()) != nil {
fieldType := n.X.Type()
for _, ix := range index[:len(index)-1] {
fieldType = deref(fieldType).Field(ix).Type
}
if fieldType.Kind() == types.TTYPEPARAM {
n.Selection = fieldType.Bound().AllMethods().Index(last)
//fmt.Printf(">>>>> %v: Bound call %v\n", base.FmtPos(pos), n.Sel)
} else {
assert(fieldType.Kind() == types.TINTER)
//fmt.Printf(">>>>> %v: Interface call %v\n", base.FmtPos(pos), n.Sel)
}
return n
}
recvObj := types2.AsNamed(recvType).Obj()
recv := g.pkg(recvObj.Pkg()).Lookup(recvObj.Name()).Def
n.Selection = recv.Type().Methods().Index(last)
//fmt.Printf(">>>>> %v: Method call %v\n", base.FmtPos(pos), n.Sel)
return n
}