Skip to content

Commit 3520955

Browse files
adonovangopherbot
authored andcommitted
go/types/typeutil: implement correct hashing of aliases
Only the Alias constructors should be ignored, not any Named ones. (The existing map_test caught this.) Change-Id: I8593bd6e7a6a00b9ea5921e402c61db948fad6bd Reviewed-on: https://go-review.googlesource.com/c/tools/+/577575 Auto-Submit: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent f6298eb commit 3520955

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

go/types/typeutil/map.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ func (h Hasher) hashFor(t types.Type) uint32 {
261261
return uint32(t.Kind())
262262

263263
case *aliases.Alias:
264-
return h.Hash(t.Underlying())
264+
return h.Hash(aliases.Unalias(t))
265265

266266
case *types.Array:
267267
return 9043 + 2*uint32(t.Len()) + 3*h.Hash(t.Elem())
@@ -462,7 +462,7 @@ func (h Hasher) shallowHash(t types.Type) uint32 {
462462
// so there's no need to optimize anything else.
463463
switch t := t.(type) {
464464
case *aliases.Alias:
465-
return h.shallowHash(t.Underlying())
465+
return h.shallowHash(aliases.Unalias(t))
466466

467467
case *types.Signature:
468468
var hash uint32 = 604171

0 commit comments

Comments
 (0)