cmd/compile: avoid double export of aliased objects

Instead of writing out the original object for each alias, ensure we
export the original object before any aliases. This allows the aliases
to simply refer back to the original object by qualified name.

Fixes #17636.

Change-Id: If80fa8c66b8fee8344a00b55d25a8aef22abd859
Reviewed-on: https://go-review.googlesource.com/32575
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Matthew Dempsky 2016-11-02 09:47:43 -07:00
parent 1a0b1cca4c
commit bcc0247331
4 changed files with 47 additions and 59 deletions

View file

@ -41,10 +41,15 @@ func exportsym(n *Node) {
}
n.Sym.Flags |= SymExport
if Debug['E'] != 0 {
fmt.Printf("export symbol %v\n", n.Sym)
}
// Ensure original object is on exportlist before aliases.
if n.Sym.Flags&SymAlias != 0 {
exportlist = append(exportlist, n.Sym.Def)
}
exportlist = append(exportlist, n)
}