diff options
author | Dan Scales <danscales@google.com> | 2021-08-09 16:00:29 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-08-10 19:48:58 +0000 |
commit | 40ba119e3f990fd570ec928307e92a5b6a76bd0e (patch) | |
tree | a0f197d224c6a95e4f96bb4a5e5693679f59a48c /src/cmd/compile/internal/typecheck/iexport.go | |
parent | fb8579746c9de74a6faa70de544286e45bc8386e (diff) | |
download | go-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/typecheck/iexport.go')
-rw-r--r-- | src/cmd/compile/internal/typecheck/iexport.go | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/cmd/compile/internal/typecheck/iexport.go b/src/cmd/compile/internal/typecheck/iexport.go index 2944908bcb..5f510a0a25 100644 --- a/src/cmd/compile/internal/typecheck/iexport.go +++ b/src/cmd/compile/internal/typecheck/iexport.go @@ -314,12 +314,7 @@ func WriteExports(out io.Writer, extensions bool) { // Assemble header. var hdr intWriter hdr.WriteByte('i') - if base.Flag.G > 0 { - hdr.uint64(iexportVersionCurrent) - } else { - // Use old export format if doing -G=0 (no generics) - hdr.uint64(iexportVersionPosCol) - } + hdr.uint64(iexportVersionCurrent) hdr.uint64(uint64(p.strings.Len())) hdr.uint64(dataLen) @@ -487,7 +482,11 @@ func (p *iexporter) doDecl(n *ir.Name) { } // Function. - w.tag('F') + if n.Type().TParams().NumFields() == 0 { + w.tag('F') + } else { + w.tag('G') + } w.pos(n.Pos()) // The tparam list of the function type is the // declaration of the type params. So, write out the type @@ -495,7 +494,7 @@ func (p *iexporter) doDecl(n *ir.Name) { // referenced via their type offset (via typOff) in all // other places in the signature and function that they // are used. - if base.Flag.G > 0 { + if n.Type().TParams().NumFields() > 0 { w.tparamList(n.Type().TParams().FieldSlice()) } w.signature(n.Type()) @@ -544,10 +543,14 @@ func (p *iexporter) doDecl(n *ir.Name) { } // Defined type. - w.tag('T') + if len(n.Type().RParams()) == 0 { + w.tag('T') + } else { + w.tag('U') + } w.pos(n.Pos()) - if base.Flag.G > 0 { + if len(n.Type().RParams()) > 0 { // Export type parameters, if any, needed for this type w.typeList(n.Type().RParams()) } |