[dev.typeparams] cmd/compile: set type parameter indices when they are bound

This is a port of CL 336249 with adjustments due to slightly
different handling of type parameter declaration in types2.

The CL also contains adjustments to the compiler front-end.

With this change it is not necessary to export type parameter
indices. Filed issue #47451 so we don't forget.

Change-Id: I2834f7be313fcb4763dff2a9058f1983ee6a81b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/338192
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Robert Griesemer 2021-07-28 15:29:19 -07:00
parent af903261e7
commit 27552e9172
23 changed files with 142 additions and 93 deletions

View file

@ -337,7 +337,7 @@ func (g *irgen) selectorExpr(pos src.XPos, typ types2.Type, expr *syntax.Selecto
if wantPtr {
recvType2Base = types2.AsPointer(recvType2).Elem()
}
if len(types2.AsNamed(recvType2Base).TParams()) > 0 {
if types2.AsNamed(recvType2Base).TParams().Len() > 0 {
// recvType2 is the original generic type that is
// instantiated for this method call.
// selinfo.Recv() is the instantiated type