[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

@ -167,10 +167,10 @@ func (g *irgen) typeDecl(out *ir.Nodes, decl *syntax.TypeDecl) {
ntyp.SetUnderlying(g.typeExpr(decl.Type))
tparams := otyp.(*types2.Named).TParams()
if len(tparams) > 0 {
rparams := make([]*types.Type, len(tparams))
if n := tparams.Len(); n > 0 {
rparams := make([]*types.Type, n)
for i := range rparams {
rparams[i] = g.typ(tparams[i].Type())
rparams[i] = g.typ(tparams.At(i).Type())
}
// This will set hasTParam flag if any rparams are not concrete types.
ntyp.SetRParams(rparams)