diff options
author | Dan Scales <danscales@google.com> | 2021-12-16 13:24:40 -0800 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-12-16 22:41:31 +0000 |
commit | 1387b5e91d76ba6727a7434c06f7c368d6c53d5c (patch) | |
tree | 017922f711865e4b57b6c3938c5502e458c50dd8 /src/cmd/compile | |
parent | b1a53ece68d46e4fb59c74d2bc529060861f5dbf (diff) | |
download | go-1387b5e91d76ba6727a7434c06f7c368d6c53d5c.tar.gz go-1387b5e91d76ba6727a7434c06f7c368d6c53d5c.zip |
cmd/compile: only avoid escaping package paths for "go.shape"
We have code that intends to avoid escaping the package path for
built-in packages. But it is hard to determine which packages are
built-in from a general rule, and we really only want to avoid escaping
for the "go.shape" package (since that gives ugly shape type names). So,
fix the code to only avoid escaping the package path specifically for
the "go.shape" package.
Fixes #50200
Change-Id: Ibaedd7690b99a173007c608c5dfa783ef82b326d
Reviewed-on: https://go-review.googlesource.com/c/go/+/372934
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Diffstat (limited to 'src/cmd/compile')
-rw-r--r-- | src/cmd/compile/internal/types/pkg.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/types/pkg.go b/src/cmd/compile/internal/types/pkg.go index 0b822a450c..b159eb5eeb 100644 --- a/src/cmd/compile/internal/types/pkg.go +++ b/src/cmd/compile/internal/types/pkg.go @@ -9,7 +9,6 @@ import ( "cmd/internal/objabi" "fmt" "sort" - "strings" "sync" ) @@ -49,9 +48,11 @@ func NewPkg(path, name string) *Pkg { p := new(Pkg) p.Path = path p.Name = name - if strings.HasPrefix(path, "go.") && !strings.Contains(path, "/") { - // Special compiler-internal packages don't need to be escaped. - // This particularly helps with the go.shape package. + if path == "go.shape" { + // Don't escape "go.shape", since it's not needed (it's a builtin + // package), and we don't want escape codes showing up in shape type + // names, which also appear in names of function/method + // instantiations. p.Prefix = path } else { p.Prefix = objabi.PathToPrefix(path) |