mirror of
https://github.com/golang/go
synced 2024-11-23 03:30:02 -07:00
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: Robert Griesemer <gri@golang.org>
This commit is contained in:
parent
148a26539b
commit
ae2a2d12f6
@ -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
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user