aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/importer/iimport.go
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-08-09 16:00:29 -0700
committerDan Scales <danscales@google.com>2021-08-10 19:48:58 +0000
commit40ba119e3f990fd570ec928307e92a5b6a76bd0e (patch)
treea0f197d224c6a95e4f96bb4a5e5693679f59a48c /src/cmd/compile/internal/importer/iimport.go
parentfb8579746c9de74a6faa70de544286e45bc8386e (diff)
downloadgo-40ba119e3f990fd570ec928307e92a5b6a76bd0e.tar.gz
go-40ba119e3f990fd570ec928307e92a5b6a76bd0e.zip
[dev.typeparams] cmd/compile: keep export format unchanged if no type params are exported
Added new export tags 'G' and 'U' to export parameterized functions/methods and parameterized types respectively. This has the advantage that the Go 1.18 format remains backward-compatible with the Go 1.17 format if no type parameters are exported. Change-Id: I9dba8faaa65609eb3f9c693bd0c79daee98bd865 Reviewed-on: https://go-review.googlesource.com/c/go/+/340989 Trust: Dan Scales <danscales@google.com> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'src/cmd/compile/internal/importer/iimport.go')
-rw-r--r--src/cmd/compile/internal/importer/iimport.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/importer/iimport.go b/src/cmd/compile/internal/importer/iimport.go
index 99eb964415..6051cdaf23 100644
--- a/src/cmd/compile/internal/importer/iimport.go
+++ b/src/cmd/compile/internal/importer/iimport.go
@@ -308,19 +308,18 @@ func (r *importReader) obj(name string) {
r.declare(types2.NewConst(pos, r.currPkg, name, typ, val))
- case 'F':
+ case 'F', 'G':
var tparams []*types2.TypeName
- if r.p.exportVersion >= iexportVersionGenerics {
+ if tag == 'G' {
tparams = r.tparamList()
}
sig := r.signature(nil)
sig.SetTParams(tparams)
-
r.declare(types2.NewFunc(pos, r.currPkg, name, sig))
- case 'T':
+ case 'T', 'U':
var tparams []*types2.TypeName
- if r.p.exportVersion >= iexportVersionGenerics {
+ if tag == 'U' {
tparams = r.tparamList()
}
@@ -328,7 +327,9 @@ func (r *importReader) obj(name string) {
// declaration before recursing.
obj := types2.NewTypeName(pos, r.currPkg, name, nil)
named := types2.NewNamed(obj, nil, nil)
- named.SetTParams(tparams)
+ if tag == 'U' {
+ named.SetTParams(tparams)
+ }
r.declare(obj)
underlying := r.p.typAt(r.uint64(), named).Underlying()