diff options
author | Dan Scales <danscales@google.com> | 2021-04-14 09:34:17 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-05-21 04:03:26 +0000 |
commit | 7b3ee6102d4690c768a7a4b303a89f3f8c811124 (patch) | |
tree | 5eb0be60a9203839698d2cf76eac4b8c5c188f0f /src/cmd/compile/internal/typecheck/iimport.go | |
parent | 15ad61aff5e6b7774101483a933b3d975ae9bae8 (diff) | |
download | go-7b3ee6102d4690c768a7a4b303a89f3f8c811124.tar.gz go-7b3ee6102d4690c768a7a4b303a89f3f8c811124.zip |
[dev.typeparams] cmd/compile: move to new export version, keep reading previous version
I added constants for the previous export versions, and for the final
generics export version. I also added a const for the current export
version. We can increment the current export version for unstable
changes in dev.typeparams, and eventally set it back to the generics
version (2) before release. Added the same constants in
typecheck/iexport.go, importer/iimport.go, and gcimporter/iimport.go,
must be kept in sync.
Put in the needed conditionals to be able to read old versions.
Added new export/import test listimp.dir.
Change-Id: I166d17d943e07951aa752562e952b067704aeeca
Reviewed-on: https://go-review.googlesource.com/c/go/+/319931
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/typecheck/iimport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iimport.go | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/typecheck/iimport.go b/src/cmd/compile/internal/typecheck/iimport.go index b6f227bb00..778ce4be12 100644 --- a/src/cmd/compile/internal/typecheck/iimport.go +++ b/src/cmd/compile/internal/typecheck/iimport.go @@ -121,8 +121,14 @@ func ReadImports(pkg *types.Pkg, in *bio.Reader) (fingerprint goobj.FingerprintT ird := &intReader{in, pkg} version := ird.uint64() - if version != iexportVersion { - base.Errorf("import %q: unknown export format version %d", pkg.Path, version) + switch version { + case iexportVersionCurrent, iexportVersionPosCol, iexportVersionGo1_11: + default: + if version > iexportVersionGenerics { + base.Errorf("import %q: unstable export format version %d, just recompile", pkg.Path, version) + } else { + base.Errorf("import %q: unknown export format version %d", pkg.Path, version) + } base.ErrorExit() } @@ -143,7 +149,8 @@ func ReadImports(pkg *types.Pkg, in *bio.Reader) (fingerprint goobj.FingerprintT in.MustSeek(int64(sLen+dLen), os.SEEK_CUR) p := &iimporter{ - ipkg: pkg, + exportVersion: version, + ipkg: pkg, pkgCache: map[uint64]*types.Pkg{}, posBaseCache: map[uint64]*src.PosBase{}, @@ -212,7 +219,8 @@ func ReadImports(pkg *types.Pkg, in *bio.Reader) (fingerprint goobj.FingerprintT } type iimporter struct { - ipkg *types.Pkg + exportVersion uint64 + ipkg *types.Pkg pkgCache map[uint64]*types.Pkg posBaseCache map[uint64]*src.PosBase @@ -314,7 +322,10 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name { return n case 'F': - tparams := r.tparamList() + var tparams []*types.Field + if r.p.exportVersion >= iexportVersionGenerics { + tparams = r.tparamList() + } typ := r.signature(nil, tparams) n := importfunc(r.p.ipkg, pos, sym, typ) @@ -322,7 +333,10 @@ func (r *importReader) doDecl(sym *types.Sym) *ir.Name { return n case 'T': - rparams := r.typeList() + var rparams []*types.Type + if r.p.exportVersion >= iexportVersionGenerics { + rparams = r.typeList() + } // Types can be recursive. We need to setup a stub // declaration before recursing. @@ -738,6 +752,9 @@ func (r *importReader) typ1() *types.Type { return t case typeParamType: + if r.p.exportVersion < iexportVersionGenerics { + base.Fatalf("unexpected type param type") + } r.setPkg() pos := r.pos() name := r.string() @@ -761,6 +778,9 @@ func (r *importReader) typ1() *types.Type { return t case instType: + if r.p.exportVersion < iexportVersionGenerics { + base.Fatalf("unexpected instantiation type") + } pos := r.pos() len := r.uint64() targs := make([]*types.Type, len) |