cmd/compile/internal/noder: remove unified IR assumptions on LocalPkg.Path == ""

Replace `pkg.Path == ""` check with `pkg == types.LocalPkg`. This is a
prep refactoring for CL 393715, which will properly initialize
types.LocalPkg.

Updates #51734.

Change-Id: I7a5428ef1f422de396762b6bc6d323992834b27c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406056
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
Matthew Dempsky 2022-05-12 15:45:13 -07:00
parent b6c5a5baa7
commit 1973be519a
3 changed files with 4 additions and 4 deletions

View file

@ -153,7 +153,7 @@ func (l *linker) relocObj(pr *pkgReader, idx int) int {
l.relocCommon(pr, &wdict, pkgbits.RelocObjDict, idx)
var obj *ir.Name
if path == "" {
if sym.Pkg == types.LocalPkg {
var ok bool
obj, ok = sym.Def.(*ir.Name)

View file

@ -295,13 +295,13 @@ func (r *reader) doPkg() *types.Pkg {
if pkg.Name == "" {
pkg.Name = name
} else {
assert(pkg.Name == name)
base.Assertf(pkg.Name == name, "package %q has name %q, but want %q", pkg.Path, pkg.Name, name)
}
if pkg.Height == 0 {
pkg.Height = height
} else {
assert(pkg.Height == height)
base.Assertf(pkg.Height == height, "package %q has height %v, but want %v", pkg.Path, pkg.Height, height)
}
return pkg

View file

@ -232,7 +232,7 @@ func readPackage(pr *pkgReader, importpkg *types.Pkg) {
r := pr.newReader(pkgbits.RelocMeta, pkgbits.PublicRootIdx, pkgbits.SyncPublic)
pkg := r.pkg()
assert(pkg == importpkg)
base.Assertf(pkg == importpkg, "have package %q (%p), want package %q (%p)", pkg.Path, pkg, importpkg.Path, importpkg)
if r.Bool() {
sym := pkg.Lookup(".inittask")