File tree 2 files changed +12
-6
lines changed
compiler/src/dotty/tools/dotc/core 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -7,9 +7,8 @@ import annotation.tailrec
7
7
8
8
object Hashable {
9
9
10
- class Binders (tp : BindingType , next : Binders ) {
11
- val hash : Int = if (next == null ) 31 else next.hash * 41 + 31
12
- }
10
+ class Binders (val tp : BindingType , val next : Binders )
11
+
13
12
class BinderPairs (tp1 : BindingType , tp2 : BindingType , next : BinderPairs ) {
14
13
@ tailrec final def matches (t1 : Type , t2 : Type ): Boolean =
15
14
(t1 `eq` tp1) && (t2 `eq` tp2) || next != null && next.matches(t1, t2)
@@ -107,7 +106,7 @@ trait Hashable {
107
106
if (elemHash == NotCached ) NotCached
108
107
else avoidSpecialHashes(elemHash + delta)
109
108
110
- private def avoidSpecialHashes (h : Int ) =
109
+ protected def avoidSpecialHashes (h : Int ) =
111
110
if (h == NotCached ) NotCachedAlt
112
111
else if (h == HashUnknown ) HashUnknownAlt
113
112
else h
Original file line number Diff line number Diff line change @@ -1528,8 +1528,15 @@ object Types {
1528
1528
*/
1529
1529
trait BindingType extends Type {
1530
1530
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
+ }
1533
1540
1534
1541
def equalBinder (that : BindingType , bs : BinderPairs ): Boolean =
1535
1542
(this `eq` that) || bs != null && bs.matches(this , that)
You can’t perform that action at this time.
0 commit comments