Skip to content

Commit e90d759

Browse files
committed
Fix identityHash for BindingTypes
1 parent dab5e51 commit e90d759

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,15 @@ object Types {
15281528
*/
15291529
trait BindingType extends Type {
15301530

1531-
override def identityHash(bs: Binders) =
1532-
if (bs == null) super.identityHash(bs) else bs.hash
1531+
override def identityHash(bs: Binders) = {
1532+
def recur(n: Int, tp: BindingType, rest: Binders): Int =
1533+
if (this `eq` tp) finishHash(hashing.mix(hashSeed, n), 1)
1534+
else if (rest == null) System.identityHashCode(this)
1535+
else recur(n + 1, rest.tp, rest.next)
1536+
avoidSpecialHashes(
1537+
if (bs == null) System.identityHashCode(this)
1538+
else recur(1, bs.tp, bs.next))
1539+
}
15331540

15341541
def equalBinder(that: BindingType, bs: BinderPairs): Boolean =
15351542
(this `eq` that) || bs != null && bs.matches(this, that)

0 commit comments

Comments
 (0)