From: Matthew Dempsky Date: Tue, 20 Dec 2022 20:00:36 +0000 (-0800) Subject: cmd/compile/internal/pkginit: remove dependency on typecheck.Resolve X-Git-Tag: go1.21rc1~1788 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6d4101ea68477bf1d762f7466523de0b95bec0ca;p=gostls13.git cmd/compile/internal/pkginit: remove dependency on typecheck.Resolve The use of typecheck.Resolve was previously necessary to interoperate with the non-unified frontend, because it hooked into iimport. It's no longer necessary with unified IR, where we can just lookup the ".inittask" symbol and access Def directly. Updates #57410. Change-Id: I73bdfd53f65988ececd2b777743cd8b591a6db48 Reviewed-on: https://go-review.googlesource.com/c/go/+/458616 Auto-Submit: Matthew Dempsky TryBot-Result: Gopher Robot Reviewed-by: Keith Randall Run-TryBot: Matthew Dempsky Reviewed-by: Keith Randall --- diff --git a/src/cmd/compile/internal/pkginit/init.go b/src/cmd/compile/internal/pkginit/init.go index e13a7fbfe0..57593fdb9b 100644 --- a/src/cmd/compile/internal/pkginit/init.go +++ b/src/cmd/compile/internal/pkginit/init.go @@ -75,14 +75,14 @@ func Task() *ir.Name { // Find imported packages with init tasks. for _, pkg := range typecheck.Target.Imports { - n := typecheck.Resolve(ir.NewIdent(base.Pos, pkg.Lookup(".inittask"))) - if n.Op() == ir.ONONAME { + n, ok := pkg.Lookup(".inittask").Def.(*ir.Name) + if !ok { continue } - if n.Op() != ir.ONAME || n.(*ir.Name).Class != ir.PEXTERN { + if n.Op() != ir.ONAME || n.Class != ir.PEXTERN { base.Fatalf("bad inittask: %v", n) } - deps = append(deps, n.(*ir.Name).Linksym()) + deps = append(deps, n.Linksym()) } if base.Flag.ASan { // Make an initialization function to call runtime.asanregisterglobals to register an