From b86d29eda5166c6e8033215a1615fdab33a5de40 Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Wed, 26 Jun 2013 18:01:00 -0400 Subject: Adds equals and hashCode to three classes that implement Ordered. --- src/compiler/scala/tools/nsc/backend/icode/Members.scala | 8 ++++++++ src/reflect/scala/reflect/internal/util/Statistics.scala | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/compiler/scala/tools/nsc/backend/icode/Members.scala b/src/compiler/scala/tools/nsc/backend/icode/Members.scala index 4389afb2b7..91bd39232e 100644 --- a/src/compiler/scala/tools/nsc/backend/icode/Members.scala +++ b/src/compiler/scala/tools/nsc/backend/icode/Members.scala @@ -108,6 +108,14 @@ trait Members { if (symbol eq other.symbol) 0 else if (symbol isLess other.symbol) -1 else 1 + + override def equals(other: Any): Boolean = + other match { + case other: IMember => (this compare other) == 0 + case _ => false + } + + override def hashCode = symbol.## } /** Represent a class in ICode */ diff --git a/src/reflect/scala/reflect/internal/util/Statistics.scala b/src/reflect/scala/reflect/internal/util/Statistics.scala index b583137059..905f1bf26e 100644 --- a/src/reflect/scala/reflect/internal/util/Statistics.scala +++ b/src/reflect/scala/reflect/internal/util/Statistics.scala @@ -133,6 +133,12 @@ quant) if (this.value < that.value) -1 else if (this.value > that.value) 1 else 0 + override def equals(that: Any): Boolean = + that match { + case that: Counter => (this compare that) == 0 + case _ => false + } + override def hashCode = value override def toString = value.toString } @@ -184,6 +190,12 @@ quant) if (this.specificNanos < that.specificNanos) -1 else if (this.specificNanos > that.specificNanos) 1 else 0 + override def equals(that: Any): Boolean = + that match { + case that: StackableTimer => (this compare that) == 0 + case _ => false + } + override def hashCode = specificNanos.## override def toString = s"${super.toString} aggregate, ${show(specificNanos)} specific" } -- cgit v1.2.3