Skip to content

Commit f838a74

Browse files
committed
Merge pull request #946 from dotty-staging/more-predictable-hashes
Make hash codes on type more predictable.
2 parents d3ba65d + c11646c commit f838a74

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/dotty/tools/dotc/core/Hashable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Hashable {
2828
trait Hashable {
2929
import Hashable._
3030

31-
protected def hashSeed: Int = getClass.hashCode
31+
protected def hashSeed: Int = getClass.getSimpleName.hashCode
3232

3333
protected final def finishHash(hashCode: Int, arity: Int): Int =
3434
avoidNotCached(hashing.finalizeHash(hashCode, arity))

src/dotty/tools/dotc/core/Uniques.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ object Uniques {
9292
}
9393

9494
final class RefinedUniques extends HashSet[RefinedType](Config.initialUniquesCapacity) with Hashable {
95-
override val hashSeed = classOf[CachedRefinedType].hashCode // some types start life as CachedRefinedTypes, need to have same hash seed
95+
override val hashSeed = "CachedRefinedType".hashCode // some types start life as CachedRefinedTypes, need to have same hash seed
9696
override def hash(x: RefinedType): Int = x.hash
9797

9898
private def findPrevious(h: Int, parent: Type, refinedName: Name, refinedInfo: Type): RefinedType = {

0 commit comments

Comments
 (0)