diff options
author | Matthew Dempsky <mdempsky@google.com> | 2021-06-25 10:04:51 -0700 |
---|---|---|
committer | Matthew Dempsky <mdempsky@google.com> | 2021-06-25 23:10:17 +0000 |
commit | 942edc750292060450fda38835c452f6125447c3 (patch) | |
tree | cda8f0643ba64df9760023d818a4e85636fb3b92 /src/cmd/compile/internal/reflectdata/reflect.go | |
parent | 373ca3a846d64733b0391dcdcc55631904a3c41c (diff) | |
download | go-942edc750292060450fda38835c452f6125447c3.tar.gz go-942edc750292060450fda38835c452f6125447c3.zip |
[dev.typeparams] cmd/compile: rename types.Type.{Short,Long}String to {Link,Name}String
The original names "ShortString" and "LongString" refer back to the
fmt verbs used to request their formatting styles. However, I always
get confused working with them, in particular because (1) the
"ShortString" description, which uses package-path qualification, is
actually generally longer than the "LongString" description, which
uses package-name qualification; and (2) the documentation mentions
how they're often used, but doesn't actually describe why they're safe
for those purposes.
This CL renames them to "LinkString" and "NameString", respectively,
based on their primary use cases. It also attempts to more completely
describe the strings they return and how they can be used correctly.
Change-Id: I9158ae3eafa8ac53da31a78c7a6d929dc0199afe
Reviewed-on: https://go-review.googlesource.com/c/go/+/330910
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/reflectdata/reflect.go')
-rw-r--r-- | src/cmd/compile/internal/reflectdata/reflect.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 8421e36b3d..316c7eb293 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -717,7 +717,7 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int { } exported := false - p := t.LongString() + p := t.NameString() // If we're writing out type T, // we are very likely to write out type *T as well. // Use the string "*T"[1:] for "T", so that the two @@ -781,11 +781,11 @@ func dcommontype(lsym *obj.LSym, t *types.Type) int { // TrackSym returns the symbol for tracking use of field/method f, assumed // to be a member of struct/interface type t. func TrackSym(t *types.Type, f *types.Field) *obj.LSym { - return base.PkgLinksym("go.track", t.ShortString()+"."+f.Sym.Name, obj.ABI0) + return base.PkgLinksym("go.track", t.LinkString()+"."+f.Sym.Name, obj.ABI0) } func TypeSymPrefix(prefix string, t *types.Type) *types.Sym { - p := prefix + "." + t.ShortString() + p := prefix + "." + t.LinkString() s := types.TypeSymLookup(p) // This function is for looking up type-related generated functions @@ -833,7 +833,7 @@ func TypePtr(t *types.Type) *ir.AddrExpr { // ITabAddr returns an expression representing a pointer to the itab // for concrete type typ implementing interface iface. func ITabAddr(typ, iface *types.Type) *ir.AddrExpr { - s, existed := ir.Pkgs.Itab.LookupOK(typ.ShortString() + "," + iface.ShortString()) + s, existed := ir.Pkgs.Itab.LookupOK(typ.LinkString() + "," + iface.LinkString()) lsym := s.Linksym() if !existed { |