@@ -3,10 +3,16 @@ package core
3
3
4
4
import Types ._
5
5
import scala .util .hashing .{ MurmurHash3 => hashing }
6
+ import annotation .tailrec
6
7
7
8
object Hashable {
8
9
9
- type Binders = Array [BindingType ]
10
+ class Binders (val tp : BindingType , val next : Binders )
11
+
12
+ class BinderPairs (tp1 : BindingType , tp2 : BindingType , next : BinderPairs ) {
13
+ @ tailrec final def matches (t1 : Type , t2 : Type ): Boolean =
14
+ (t1 `eq` tp1) && (t2 `eq` tp2) || next != null && next.matches(t1, t2)
15
+ }
10
16
11
17
/** A hash value indicating that the underlying type is not
12
18
* cached in uniques.
@@ -36,7 +42,7 @@ trait Hashable {
36
42
avoidSpecialHashes(hashing.finalizeHash(hashCode, arity))
37
43
38
44
final def typeHash (bs : Binders , tp : Type ) =
39
- if (bs == null ) tp.hash else tp.computeHash(bs)
45
+ if (bs == null || tp.stableHash ) tp.hash else tp.computeHash(bs)
40
46
41
47
def identityHash (bs : Binders ) = avoidSpecialHashes(System .identityHashCode(this ))
42
48
@@ -93,15 +99,14 @@ trait Hashable {
93
99
protected final def doHash (bs : Binders , x1 : Any , tp2 : Type , tps3 : List [Type ]): Int =
94
100
finishHash(bs, hashing.mix(hashSeed, x1.hashCode), 1 , tp2, tps3)
95
101
96
-
97
- protected final def doHash (bs : Binders , x1 : Int , x2 : Int ): Int =
102
+ protected final def doHash (x1 : Int , x2 : Int ): Int =
98
103
finishHash(hashing.mix(hashing.mix(hashSeed, x1), x2), 1 )
99
104
100
105
protected final def addDelta (elemHash : Int , delta : Int ) =
101
106
if (elemHash == NotCached ) NotCached
102
107
else avoidSpecialHashes(elemHash + delta)
103
108
104
- private def avoidSpecialHashes (h : Int ) =
109
+ protected def avoidSpecialHashes (h : Int ) =
105
110
if (h == NotCached ) NotCachedAlt
106
111
else if (h == HashUnknown ) HashUnknownAlt
107
112
else h
0 commit comments