From 63505c28506445216e883309237c84448ce11a7d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 9 Dec 2014 11:35:02 +0100 Subject: Add equality method to TypeBounds. Curiously, was missing before, which meant variance was ignored when hash-consing TypeBounds. --- src/dotty/tools/dotc/core/Types.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/dotty/tools/dotc/core/Types.scala') diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala index 017b7cadc..d9228a5da 100644 --- a/src/dotty/tools/dotc/core/Types.scala +++ b/src/dotty/tools/dotc/core/Types.scala @@ -2451,6 +2451,13 @@ object Types { /** If this type and that type have the same variance, this variance, otherwise 0 */ final def commonVariance(that: TypeBounds): Int = (this.variance + that.variance) / 2 + override def equals(that: Any): Boolean = that match { + case that: TypeBounds => + (this.lo eq that.lo) && (this.hi eq that.hi) && this.variance == that.variance + case _ => + false + } + override def toString = if (lo eq hi) s"TypeAlias($lo)" else s"TypeBounds($lo, $hi)" -- cgit v1.2.3