From 4170084ad12c2e14dc0485d2a17a838e97fee8c7 Mon Sep 17 00:00:00 2001 From: Matthew Dempsky Date: Thu, 12 May 2022 15:47:21 -0700 Subject: [PATCH] cmd/compile/internal/ir: remove PkgFuncName assumption that LocalPkg.Path == "" Prep refactoring for CL 393715, after which LocalPkg.Path will no longer be the empty string. Instead of testing `pkg.Path == ""`, we can just test `pkg == LocalPkg`. Updates #51734. Change-Id: I74fff7fb383e275c9f294389d30b2220aced19e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/406059 Reviewed-by: David Chase Run-TryBot: Matthew Dempsky TryBot-Result: Gopher Robot --- src/cmd/compile/internal/ir/func.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go index a9a7f19d3f6..f90c87126f8 100644 --- a/src/cmd/compile/internal/ir/func.go +++ b/src/cmd/compile/internal/ir/func.go @@ -268,14 +268,14 @@ func PkgFuncName(f *Func) string { s := f.Sym() pkg := s.Pkg - p := base.Ctxt.Pkgpath - if pkg != nil && pkg.Path != "" { - p = pkg.Path - } - if p == "" { + // TODO(mdempsky): Remove after submitting CL 393715? This matches + // how PkgFuncName has historically handled local functions, but + // drchase points out it contradicts the documentation. + if pkg == types.LocalPkg { return s.Name } - return p + "." + s.Name + + return pkg.Path + "." + s.Name } var CurFunc *Func