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: Robert Griesemer <gri@golang.org>
// (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)
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
}