]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/ir: remove PkgFuncName assumption that LocalPkg.Path == ""
authorMatthew Dempsky <mdempsky@google.com>
Thu, 12 May 2022 22:47:21 +0000 (15:47 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Fri, 13 May 2022 21:33:25 +0000 (21:33 +0000)
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 <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

src/cmd/compile/internal/ir/func.go

index a9a7f19d3f669e6eab1a32ea777b07ad2a8904f1..f90c87126f8c4d25d073614bdaaafc2dafc0dcdf 100644 (file)
@@ -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