mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
Revert "cmd/compile: skip reexporting types in reexportdep"
This reverts commit edad59cfae.
Fixes #20682.
Change-Id: If998c8b4bf177d5da9e26f75579bd5497ec86d38
Reviewed-on: https://go-review.googlesource.com/45911
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
7d21123995
commit
8d2b3bb7b1
2 changed files with 81 additions and 1 deletions
|
|
@ -506,6 +506,13 @@ func (p *exporter) obj(sym *types.Sym) {
|
||||||
var f *Func
|
var f *Func
|
||||||
if inlineable {
|
if inlineable {
|
||||||
f = asNode(sym.Def).Func
|
f = asNode(sym.Def).Func
|
||||||
|
// TODO(gri) re-examine reexportdeplist:
|
||||||
|
// Because we can trivially export types
|
||||||
|
// in-place, we don't need to collect types
|
||||||
|
// inside function bodies in the exportlist.
|
||||||
|
// With an adjusted reexportdeplist used only
|
||||||
|
// by the binary exporter, we can also avoid
|
||||||
|
// the global exportlist.
|
||||||
reexportdeplist(f.Inl)
|
reexportdeplist(f.Inl)
|
||||||
}
|
}
|
||||||
p.funcList = append(p.funcList, f)
|
p.funcList = append(p.funcList, f)
|
||||||
|
|
@ -698,7 +705,7 @@ func (p *exporter) typ(t *types.Type) {
|
||||||
var f *Func
|
var f *Func
|
||||||
if inlineable {
|
if inlineable {
|
||||||
f = mfn.Func
|
f = mfn.Func
|
||||||
reexportdeplist(f.Inl)
|
reexportdeplist(mfn.Func.Inl)
|
||||||
}
|
}
|
||||||
p.funcList = append(p.funcList, f)
|
p.funcList = append(p.funcList, f)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ func reexportdep(n *Node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//print("reexportdep %+hN\n", n);
|
||||||
switch n.Op {
|
switch n.Op {
|
||||||
case ONAME:
|
case ONAME:
|
||||||
switch n.Class() {
|
switch n.Class() {
|
||||||
|
|
@ -131,6 +132,78 @@ func reexportdep(n *Node) {
|
||||||
exportlist = append(exportlist, n)
|
exportlist = append(exportlist, n)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Local variables in the bodies need their type.
|
||||||
|
case ODCL:
|
||||||
|
t := n.Left.Type
|
||||||
|
|
||||||
|
if t != types.Types[t.Etype] && t != types.Idealbool && t != types.Idealstring {
|
||||||
|
if t.IsPtr() {
|
||||||
|
t = t.Elem()
|
||||||
|
}
|
||||||
|
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
||||||
|
if Debug['E'] != 0 {
|
||||||
|
fmt.Printf("reexport type %v from declaration\n", t.Sym)
|
||||||
|
}
|
||||||
|
exportlist = append(exportlist, asNode(t.Sym.Def))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
case OLITERAL:
|
||||||
|
t := n.Type
|
||||||
|
if t != types.Types[n.Type.Etype] && t != types.Idealbool && t != types.Idealstring {
|
||||||
|
if t.IsPtr() {
|
||||||
|
t = t.Elem()
|
||||||
|
}
|
||||||
|
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
||||||
|
if Debug['E'] != 0 {
|
||||||
|
fmt.Printf("reexport literal type %v\n", t.Sym)
|
||||||
|
}
|
||||||
|
exportlist = append(exportlist, asNode(t.Sym.Def))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fallthrough
|
||||||
|
|
||||||
|
case OTYPE:
|
||||||
|
if n.Sym != nil && n.Sym.Def != nil && !exportedsym(n.Sym) {
|
||||||
|
if Debug['E'] != 0 {
|
||||||
|
fmt.Printf("reexport literal/type %v\n", n.Sym)
|
||||||
|
}
|
||||||
|
exportlist = append(exportlist, n)
|
||||||
|
}
|
||||||
|
|
||||||
|
// for operations that need a type when rendered, put the type on the export list.
|
||||||
|
case OCONV,
|
||||||
|
OCONVIFACE,
|
||||||
|
OCONVNOP,
|
||||||
|
ORUNESTR,
|
||||||
|
OARRAYBYTESTR,
|
||||||
|
OARRAYRUNESTR,
|
||||||
|
OSTRARRAYBYTE,
|
||||||
|
OSTRARRAYRUNE,
|
||||||
|
ODOTTYPE,
|
||||||
|
ODOTTYPE2,
|
||||||
|
OSTRUCTLIT,
|
||||||
|
OARRAYLIT,
|
||||||
|
OSLICELIT,
|
||||||
|
OPTRLIT,
|
||||||
|
OMAKEMAP,
|
||||||
|
OMAKESLICE,
|
||||||
|
OMAKECHAN:
|
||||||
|
t := n.Type
|
||||||
|
|
||||||
|
switch t.Etype {
|
||||||
|
case TARRAY, TCHAN, TPTR32, TPTR64, TSLICE:
|
||||||
|
if t.Sym == nil {
|
||||||
|
t = t.Elem()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if t != nil && t.Sym != nil && t.Sym.Def != nil && !exportedsym(t.Sym) {
|
||||||
|
if Debug['E'] != 0 {
|
||||||
|
fmt.Printf("reexport type for expression %v\n", t.Sym)
|
||||||
|
}
|
||||||
|
exportlist = append(exportlist, asNode(t.Sym.Def))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reexportdep(n.Left)
|
reexportdep(n.Left)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue