From: Matthew Dempsky Date: Mon, 6 Mar 2017 20:57:44 +0000 (-0800) Subject: cmd/compile: preserve Type.nod in copytype X-Git-Tag: go1.9beta1~1270 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=5d0c20efc7bb373107535543f75741465fe93d3f;p=gostls13.git cmd/compile: preserve Type.nod in copytype By clearing out t.nod in copytype, we effectively lose the reference from a Type back to its declaring OTYPE Node. This means later in typenamesym when we add typenod(t) to signatlist, we end up creating a new OTYPE Node. Moreover, this Node's position information will depend on whatever context it happens be needed, and will be used for the Type's position in the export data. Updates #19391. Change-Id: Ied93126449f75d7c5e3275cbdcc6fa657a8aa21d Reviewed-on: https://go-review.googlesource.com/37870 Run-TryBot: Matthew Dempsky Run-TryBot: Robert Griesemer TryBot-Result: Gobot Gobot Reviewed-by: Robert Griesemer --- diff --git a/src/cmd/compile/internal/gc/bimport.go b/src/cmd/compile/internal/gc/bimport.go index 34cb70d9c8..d6a25515df 100644 --- a/src/cmd/compile/internal/gc/bimport.go +++ b/src/cmd/compile/internal/gc/bimport.go @@ -404,12 +404,10 @@ func (p *importer) newtyp(etype EType) *Type { // importtype declares that pt, an imported named type, has underlying type t. func (p *importer) importtype(pt, t *Type) { if pt.Etype == TFORW { - n := pt.nod copytype(pt.nod, t) - pt.nod = n // unzero nod pt.Sym.Importdef = importpkg pt.Sym.Lastlineno = lineno - declare(n, PEXTERN) + declare(pt.nod, PEXTERN) checkwidth(pt) } else { // pt.Orig and t must be identical. diff --git a/src/cmd/compile/internal/gc/typecheck.go b/src/cmd/compile/internal/gc/typecheck.go index 4923c3ec8a..180bd70cc1 100644 --- a/src/cmd/compile/internal/gc/typecheck.go +++ b/src/cmd/compile/internal/gc/typecheck.go @@ -3566,7 +3566,7 @@ func copytype(n *Node, t *Type) { } t.methods = Fields{} t.allMethods = Fields{} - t.nod = nil + t.nod = n t.SetDeferwidth(false) t.ptrTo = ptrTo t.sliceOf = sliceOf