diff options
author | Dan Scales <danscales@google.com> | 2021-08-06 16:29:09 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-08-07 06:00:09 +0000 |
commit | d10a90471275bf2d91c4c853d7d1f75f23a70a32 (patch) | |
tree | 53ac7210fa0056404aa3d7e0346de3d58945b5cf /src/cmd/compile/internal/typecheck/iimport.go | |
parent | 9e0ac72d680e71d22c7d31950a16d4f92f08305a (diff) | |
download | go-d10a90471275bf2d91c4c853d7d1f75f23a70a32.tar.gz go-d10a90471275bf2d91c4c853d7d1f75f23a70a32.zip |
[dev.typeparams] cmd/compile: don't export/import type parameter indices anymore
types2 now determines type parameter indices lazily, so we don't need
them just as we are importing. We set them in types1 as we are importing
the type param list itself.
type param indices are not strongly needed in types1 - we only use them
in one place which could be rewritten. But I kept them in analogy to
types2 (TypeParam.Index).
Fixes #47451
Change-Id: I30631f95c45a259354eaf7ec5194f71e799eb358
Reviewed-on: https://go-review.googlesource.com/c/go/+/340532
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iimport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iimport.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index 2957212fb2..2e8b18c0b7 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -388,8 +388,9 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name { // this types2-to-types1 translation. return sym.Def.(*ir.Name) } - index := int(r.int64()) - t := types.NewTypeParam(sym, index) + // The typeparam index is set at the point where the containing type + // param list is imported. + t := types.NewTypeParam(sym, 0) // Nname needed to save the pos. nname := ir.NewDeclNameAt(pos, ir.OTYPE, sym) sym.Def = nname @@ -875,6 +876,9 @@ func (r *importReader) typeList() []*types.Type { ts := make([]*types.Type, n) for i := range ts { ts[i] = r.typ() + if ts[i].IsTypeParam() { + ts[i].SetIndex(i) + } } return ts } @@ -887,6 +891,7 @@ func (r *importReader) tparamList() []*types.Field { fs := make([]*types.Field, n) for i := range fs { typ := r.typ() + typ.SetIndex(i) fs[i] = types.NewField(typ.Pos(), typ.Sym(), typ) } return fs |