Skip to content

Commit 60643c0

Browse files
timothy-kingGo LUCI
authored andcommitted
go/types/typeutil: clarify what inGenericSig applies to
Change-Id: Ib0737d7a99db3038a109aa66ac9b3caa3fff3ec9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/641455 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]> Commit-Queue: Tim King <[email protected]>
1 parent 248b94e commit 60643c0

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

go/types/typeutil/map.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,13 @@ func (h hasher) hash(t types.Type) uint32 {
257257
}
258258

259259
tparams := t.TypeParams()
260-
for i := range tparams.Len() {
261-
h.inGenericSig = true
262-
tparam := tparams.At(i)
263-
hash += 7 * h.hash(tparam.Constraint())
260+
if n := tparams.Len(); n > 0 {
261+
h.inGenericSig = true // affects constraints, params, and results
262+
263+
for i := range n {
264+
tparam := tparams.At(i)
265+
hash += 7 * h.hash(tparam.Constraint())
266+
}
264267
}
265268

266269
return hash + 3*h.hashTuple(t.Params()) + 5*h.hashTuple(t.Results())

0 commit comments

Comments
 (0)