aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-03-12 13:43:45 +0100
committerodersky <odersky@gmail.com>2016-03-12 13:43:45 +0100
commite68d68414fa346fad9dee204746d826ee172e861 (patch)
treed97b447155965ceeb81ea5a0c16778bb5ba86b6c /src
parent305a9f06bd2b2ac6070beb184d61ff6db4cb9155 (diff)
parenta4597c4e2e664f744eeb68541ddbab997afc03cc (diff)
downloaddotty-e68d68414fa346fad9dee204746d826ee172e861.tar.gz
dotty-e68d68414fa346fad9dee204746d826ee172e861.tar.bz2
dotty-e68d68414fa346fad9dee204746d826ee172e861.zip
Merge pull request #1170 from dotty-staging/fix/hash-delta
Fix incorrect hashing leading to cache pollution
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/core/Hashable.scala4
-rw-r--r--src/dotty/tools/dotc/core/Types.scala2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/core/Hashable.scala b/src/dotty/tools/dotc/core/Hashable.scala
index 6a64f8655..12a408fbd 100644
--- a/src/dotty/tools/dotc/core/Hashable.scala
+++ b/src/dotty/tools/dotc/core/Hashable.scala
@@ -92,7 +92,9 @@ trait Hashable {
protected final def doHash(x1: Int, x2: Int): Int =
finishHash(hashing.mix(hashing.mix(hashSeed, x1), x2), 1)
- protected final def addDelta(hc: Int, delta: Int) = avoidNotCached(hc + delta)
+ protected final def addDelta(elemHash: Int, delta: Int) =
+ if (elemHash == NotCached) NotCached
+ else avoidNotCached(elemHash + delta)
private def avoidNotCached(h: Int) = if (h == NotCached) NotCachedAlt else h
}
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index dd12a0188..17c2ec4ca 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -2479,7 +2479,7 @@ object Types {
def copyBoundType(bt: BT) = new MethodParamImpl(bt, paramNum)
// need to customize hashCode and equals to prevent infinite recursion for dep meth types.
- override def computeHash = addDelta(System.identityHashCode(binder), paramNum)
+ override def computeHash = addDelta(binder.identityHash, paramNum)
override def equals(that: Any) = that match {
case that: MethodParam =>
(this.binder eq that.binder) && this.paramNum == that.paramNum