aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/reflectdata/reflect.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2021-06-25 10:15:40 -0700
committerMatthew Dempsky <mdempsky@google.com>2021-06-25 23:10:23 +0000
commited647b16d02da4571c22baac23c302f2d888b88b (patch)
treeb5834ec36a08a15adaed65a5eefbb8efbb8a03bc /src/cmd/compile/internal/reflectdata/reflect.go
parent942edc750292060450fda38835c452f6125447c3 (diff)
downloadgo-ed647b16d02da4571c22baac23c302f2d888b88b.tar.gz
go-ed647b16d02da4571c22baac23c302f2d888b88b.zip
[dev.typeparams] cmd/compile: use Type.LinkString for map keys
This CL changes typecheck and order to use Type.LinkString for computing map keys instead of Type.NameString. As mentioned in the LinkString docs (added by the previous CL), LinkString reliably maps type identity to string equality as long as the LinkString calls all happen within the same compilation unit (which they do here). This eliminates the need for subsequent types.Identical checks. Change-Id: I32ff591e69d6f23f2dc6ebd5af343618ebe89013 Reviewed-on: https://go-review.googlesource.com/c/go/+/330911 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Matthew Dempsky <mdempsky@google.com> 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.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go
index 316c7eb293..351aaab399 100644
--- a/src/cmd/compile/internal/reflectdata/reflect.go
+++ b/src/cmd/compile/internal/reflectdata/reflect.go
@@ -1388,7 +1388,7 @@ func WriteBasicTypes() {
type typeAndStr struct {
t *types.Type
- short string
+ short string // "short" here means NameString
regular string
}
@@ -1401,8 +1401,13 @@ func (a typesByString) Less(i, j int) bool {
}
// When the only difference between the types is whether
// they refer to byte or uint8, such as **byte vs **uint8,
- // the types' ShortStrings can be identical.
+ // the types' NameStrings can be identical.
// To preserve deterministic sort ordering, sort these by String().
+ //
+ // TODO(mdempsky): This all seems suspect. Using LinkString would
+ // avoid naming collisions, and there shouldn't be a reason to care
+ // about "byte" vs "uint8": they share the same runtime type
+ // descriptor anyway.
if a[i].regular != a[j].regular {
return a[i].regular < a[j].regular
}