Historically, the compiler set types.LocalPkg.Path to "", so a lot of
compiler code checks for this, and then falls back to using
base.Ctxt.Pkgpath instead.
Since CL 393715, we now initialize types.LocalPkg.Path to
base.Ctxt.Pkgpath, so these code paths can now simply rely on Pkg.Path
always being meaningful.
Updates #51734.
Change-Id: I0aedbd7cf8e14edbfef781106a9510344d468f2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/406317
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
fns = append(fns, fn.Nname.Linksym())
}
- if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Name != "main" && types.LocalPkg.Name != "runtime" {
+ if len(deps) == 0 && len(fns) == 0 && types.LocalPkg.Path != "main" && types.LocalPkg.Path != "runtime" {
return nil // nothing to initialize
}
return nil
}
pkg := sym.Pkg.Path
- if sym.Pkg == types.LocalPkg {
- pkg = base.Ctxt.Pkgpath
- }
if sym.Pkg == ir.Pkgs.Runtime {
pkg = "runtime"
}
// embedKind determines the kind of embedding variable.
func embedKind(typ *types.Type) int {
- if typ.Sym() != nil && typ.Sym().Name == "FS" && (typ.Sym().Pkg.Path == "embed" || (typ.Sym().Pkg == types.LocalPkg && base.Ctxt.Pkgpath == "embed")) {
+ if typ.Sym() != nil && typ.Sym().Name == "FS" && typ.Sym().Pkg.Path == "embed" {
return embedFiles
}
if typ.Kind() == types.TSTRING {
// IsReflectPkg reports whether p is package reflect.
func IsReflectPkg(p *Pkg) bool {
- if p == LocalPkg {
- return base.Ctxt.Pkgpath == "reflect"
- }
return p.Path == "reflect"
}