Skip to content

Commit b86d29e

Browse files
committed
Adds equals and hashCode to three classes that implement Ordered.
1 parent abe4bd8 commit b86d29e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/compiler/scala/tools/nsc/backend/icode/Members.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ trait Members {
108108
if (symbol eq other.symbol) 0
109109
else if (symbol isLess other.symbol) -1
110110
else 1
111+
112+
override def equals(other: Any): Boolean =
113+
other match {
114+
case other: IMember => (this compare other) == 0
115+
case _ => false
116+
}
117+
118+
override def hashCode = symbol.##
111119
}
112120

113121
/** Represent a class in ICode */

src/reflect/scala/reflect/internal/util/Statistics.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ quant)
133133
if (this.value < that.value) -1
134134
else if (this.value > that.value) 1
135135
else 0
136+
override def equals(that: Any): Boolean =
137+
that match {
138+
case that: Counter => (this compare that) == 0
139+
case _ => false
140+
}
141+
override def hashCode = value
136142
override def toString = value.toString
137143
}
138144

@@ -184,6 +190,12 @@ quant)
184190
if (this.specificNanos < that.specificNanos) -1
185191
else if (this.specificNanos > that.specificNanos) 1
186192
else 0
193+
override def equals(that: Any): Boolean =
194+
that match {
195+
case that: StackableTimer => (this compare that) == 0
196+
case _ => false
197+
}
198+
override def hashCode = specificNanos.##
187199
override def toString = s"${super.toString} aggregate, ${show(specificNanos)} specific"
188200
}
189201

0 commit comments

Comments
 (0)