diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-07 11:52:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-07 11:52:04 +0100 |
commit | 5d590242132b0f38fc04afed2c787dadfd8d6c2f (patch) | |
tree | ff4a054c46dc003223c86b3b1731f1aeeeaa8323 | |
parent | bffefe96f1c3c550e42d745af879755d1f99bc37 (diff) | |
parent | 03b6a47f72da3229e80c7e67495cc73611aae0c9 (diff) | |
download | dotty-5d590242132b0f38fc04afed2c787dadfd8d6c2f.tar.gz dotty-5d590242132b0f38fc04afed2c787dadfd8d6c2f.tar.bz2 dotty-5d590242132b0f38fc04afed2c787dadfd8d6c2f.zip |
Merge pull request #1632 from dotty-staging/fix/hash-assert
Avoid calling unsupported computeHash in some situations
-rw-r--r-- | src/dotty/tools/dotc/core/Hashable.scala | 11 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/Types.scala | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/core/Hashable.scala b/src/dotty/tools/dotc/core/Hashable.scala index 12a408fbd..e4510c53e 100644 --- a/src/dotty/tools/dotc/core/Hashable.scala +++ b/src/dotty/tools/dotc/core/Hashable.scala @@ -31,9 +31,9 @@ trait Hashable { protected def hashSeed: Int = getClass.hashCode protected final def finishHash(hashCode: Int, arity: Int): Int = - avoidNotCached(hashing.finalizeHash(hashCode, arity)) + avoidSpecialHashes(hashing.finalizeHash(hashCode, arity)) - final def identityHash = avoidNotCached(System.identityHashCode(this)) + final def identityHash = avoidSpecialHashes(System.identityHashCode(this)) protected def finishHash(seed: Int, arity: Int, tp: Type): Int = { val elemHash = tp.hash @@ -94,7 +94,10 @@ trait Hashable { protected final def addDelta(elemHash: Int, delta: Int) = if (elemHash == NotCached) NotCached - else avoidNotCached(elemHash + delta) + else avoidSpecialHashes(elemHash + delta) - private def avoidNotCached(h: Int) = if (h == NotCached) NotCachedAlt else h + private def avoidSpecialHashes(h: Int) = + if (h == NotCached) NotCachedAlt + else if (h == HashUnknown) HashUnknownAlt + else h } diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index fda763fda..ce308412b 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -1278,7 +1278,7 @@ object Types { final def hash = { if (myHash == HashUnknown) { myHash = computeHash - if (myHash == HashUnknown) myHash = HashUnknownAlt + assert(myHash != HashUnknown) } myHash } @@ -1293,7 +1293,7 @@ object Types { final def hash = { if (myHash == HashUnknown) { myHash = computeHash - if (myHash == HashUnknown) myHash = HashUnknownAlt + assert(myHash != HashUnknown) } myHash } |