Commit ae2a2d12 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: cleaner solution for importing init functions

Using oldname+resolve is how typecheck handles this anyway.

Passes toolstash -cmp, with both -iexport enabled and disabled.

Change-Id: I12b0f0333d6b86ce6bfc4d416c461b5f15c1110d
Reviewed-on: https://go-review.googlesource.com/109715
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 148a2653
......@@ -115,12 +115,18 @@ func fninit(n []*Node) {
// (6)
for _, s := range types.InitSyms {
if s.Def != nil && s != initsym {
n := asNode(s.Def)
n.checkInitFuncSignature()
a = nod(OCALL, n, nil)
r = append(r, a)
if s == initsym {
continue
}
n := resolve(oldname(s))
if n.Op == ONONAME {
// No package-scope init function; just a
// local variable, field name, or something.
continue
}
n.checkInitFuncSignature()
a = nod(OCALL, n, nil)
r = append(r, a)
}
// (7)
......
......@@ -67,17 +67,6 @@ func parseFiles(filenames []string) uint {
localpkg.Height = myheight
if flagiexport {
// init.go requires all imported init functions to be
// fully resolved.
// TODO(mdempsky): Can this be done elsewhere more cleanly?
for _, s := range types.InitSyms {
if n := asNode(s.Def); n != nil && s.Pkg != localpkg {
resolve(n)
}
}
}
return lines
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment