Skip to content

Commit c4f9683

Browse files
committed
Fixing hashing for RefinedThis types.
... to bring it in sync with equals.
1 parent 4e287d5 commit c4f9683

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ trait Hashable {
3333
private def finishHash(hashCode: Int, arity: Int): Int =
3434
avoidNotCached(hashing.finalizeHash(hashCode, arity))
3535

36-
protected final def identityHash = avoidNotCached(System.identityHashCode(this))
36+
final def identityHash = avoidNotCached(System.identityHashCode(this))
3737

3838
private def finishHash(seed: Int, arity: Int, tp: Type): Int = {
3939
val elemHash = tp.hash

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ object Types {
17571757
}
17581758
}
17591759

1760-
// ----- Bound types: MethodParam, PolyParam, RefiendThis --------------------------
1760+
// ----- Bound types: MethodParam, PolyParam, RefinedThis --------------------------
17611761

17621762
abstract class BoundType extends CachedProxyType with ValueType {
17631763
type BT <: BindingType
@@ -1821,7 +1821,7 @@ object Types {
18211821

18221822
// need to customize hashCode and equals to prevent infinite recursion for
18231823
// refinements that refer to the refinement type via this
1824-
override def computeHash = identityHash
1824+
override def computeHash = addDelta(binder.identityHash, 41)
18251825
override def equals(that: Any) = that match {
18261826
case that: RefinedThis => this.binder eq that.binder
18271827
case _ => false

0 commit comments

Comments
 (0)