Skip to content

Commit 45f2f40

Browse files
committed
chore: port all hashCode method in the Scala 2 inherited stdlib to be nullary functions
1 parent baa13bc commit 45f2f40

File tree

15 files changed

+46
-46
lines changed

15 files changed

+46
-46
lines changed

library/src/scala/Enumeration.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ abstract class Enumeration (initial: Int) extends Serializable {
9898

9999
/** The name of this enumeration.
100100
*/
101-
override def toString: String =
101+
override def toString(): String =
102102
getClass.getName
103103
.stripSuffix(MODULE_SUFFIX_STRING)
104104
.split('.')
105-
.last
105+
.last
106106
.split(Regex.quote(NAME_JOIN_STRING))
107107
.last
108108

@@ -241,7 +241,7 @@ abstract class Enumeration (initial: Int) extends Serializable {
241241
case that: Enumeration#Value => (outerEnum eq that.outerEnum) && (id == that.id)
242242
case _ => false
243243
}
244-
override def hashCode: Int = id.##
244+
override def hashCode(): Int = id.##
245245

246246
/** Create a ValueSet which contains this value and another one */
247247
def + (v: Value): ValueSet = ValueSet(this, v)

library/src/scala/Proxy.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import scala.language.`2.13`
2929
trait Proxy extends Any {
3030
def self: Any
3131

32-
override def hashCode: Int = self.hashCode
32+
override def hashCode(): Int = self.hashCode
3333
override def equals(that: Any): Boolean = that match {
3434
case null => false
3535
case _ =>

library/src/scala/Symbol.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ final class Symbol private (val name: String) extends Serializable {
2424

2525
@throws(classOf[java.io.ObjectStreamException])
2626
private def readResolve(): Any = Symbol.apply(name)
27-
override def hashCode = name.hashCode()
27+
override def hashCode() = name.hashCode()
2828
override def equals(other: Any) = this eq other.asInstanceOf[AnyRef]
2929
}
3030

library/src/scala/collection/Iterator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ trait Iterator[+A] extends IterableOnce[A] with IterableOnceOps[A, Iterator, Ite
898898
// to verify partnerhood we use reference equality on gap because
899899
// type testing does not discriminate based on origin.
900900
private def compareGap(queue: scala.collection.mutable.Queue[A]) = gap eq queue
901-
override def hashCode = gap.hashCode()
901+
override def hashCode() = gap.hashCode()
902902
override def equals(other: Any) = other match {
903903
case x: Partner => x.compareGap(gap) && gap.isEmpty
904904
case _ => super.equals(other)

library/src/scala/collection/convert/JavaCollectionWrappers.scala

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
4141
case that: IteratorWrapper[_] => this.underlying == that.underlying
4242
case _ => false
4343
}
44-
override def hashCode: Int = underlying.hashCode()
44+
override def hashCode(): Int = underlying.hashCode()
4545
}
4646

4747
@SerialVersionUID(3L)
@@ -52,7 +52,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
5252
case that: JIteratorWrapper[_] => this.underlying == that.underlying
5353
case _ => false
5454
}
55-
override def hashCode: Int = underlying.hashCode()
55+
override def hashCode(): Int = underlying.hashCode()
5656
}
5757

5858
@SerialVersionUID(3L)
@@ -63,7 +63,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
6363
case that: JEnumerationWrapper[_] => this.underlying == that.underlying
6464
case _ => false
6565
}
66-
override def hashCode: Int = underlying.hashCode()
66+
override def hashCode(): Int = underlying.hashCode()
6767
}
6868

6969
trait IterableWrapperTrait[A] extends ju.AbstractCollection[A] {
@@ -79,7 +79,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
7979
case that: IterableWrapper[_] => this.underlying == that.underlying
8080
case _ => false
8181
}
82-
override def hashCode: Int = underlying.hashCode()
82+
override def hashCode(): Int = underlying.hashCode()
8383
}
8484

8585
@SerialVersionUID(3L)
@@ -94,7 +94,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
9494
case that: JIterableWrapper[_] => this.underlying == that.underlying
9595
case _ => false
9696
}
97-
override def hashCode: Int = underlying.hashCode()
97+
override def hashCode(): Int = underlying.hashCode()
9898
}
9999

100100
@SerialVersionUID(3L)
@@ -111,7 +111,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
111111
case that: JCollectionWrapper[_] => this.underlying == that.underlying
112112
case _ => false
113113
}
114-
override def hashCode: Int = underlying.hashCode()
114+
override def hashCode(): Int = underlying.hashCode()
115115
}
116116

117117
@SerialVersionUID(3L)
@@ -285,7 +285,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
285285
// specified in the javadocs of java.util.Map.Entry.hashCode
286286
//
287287
// See https://github.com/scala/bug/issues/10663
288-
override def hashCode = {
288+
override def hashCode() = {
289289
(if (k == null) 0 else k.hashCode()) ^
290290
(if (v == null) 0 else v.hashCode())
291291
}
@@ -552,7 +552,7 @@ private[collection] object JavaCollectionWrappers extends Serializable {
552552
case _ => false
553553
}
554554

555-
override def hashCode: Int = underlying.hashCode()
555+
override def hashCode(): Int = underlying.hashCode()
556556
}
557557

558558
@SerialVersionUID(3L)

library/src/scala/collection/immutable/ArraySeq.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
332332
def length: Int = unsafeArray.length
333333
@throws[ArrayIndexOutOfBoundsException]
334334
def apply(i: Int): T = unsafeArray(i)
335-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
335+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
336336
override def equals(that: Any): Boolean = that match {
337337
case that: ofRef[_] =>
338338
Array.equals(
@@ -363,7 +363,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
363363
def length: Int = unsafeArray.length
364364
@throws[ArrayIndexOutOfBoundsException]
365365
def apply(i: Int): Byte = unsafeArray(i)
366-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
366+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
367367
override def equals(that: Any) = that match {
368368
case that: ofByte => Arrays.equals(unsafeArray, that.unsafeArray)
369369
case _ => super.equals(that)
@@ -405,7 +405,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
405405
def length: Int = unsafeArray.length
406406
@throws[ArrayIndexOutOfBoundsException]
407407
def apply(i: Int): Short = unsafeArray(i)
408-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
408+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
409409
override def equals(that: Any) = that match {
410410
case that: ofShort => Arrays.equals(unsafeArray, that.unsafeArray)
411411
case _ => super.equals(that)
@@ -447,7 +447,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
447447
def length: Int = unsafeArray.length
448448
@throws[ArrayIndexOutOfBoundsException]
449449
def apply(i: Int): Char = unsafeArray(i)
450-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
450+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
451451
override def equals(that: Any) = that match {
452452
case that: ofChar => Arrays.equals(unsafeArray, that.unsafeArray)
453453
case _ => super.equals(that)
@@ -492,7 +492,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
492492
def length: Int = unsafeArray.length
493493
@throws[ArrayIndexOutOfBoundsException]
494494
def apply(i: Int): Int = unsafeArray(i)
495-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
495+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
496496
override def equals(that: Any) = that match {
497497
case that: ofInt => Arrays.equals(unsafeArray, that.unsafeArray)
498498
case _ => super.equals(that)
@@ -534,7 +534,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
534534
def length: Int = unsafeArray.length
535535
@throws[ArrayIndexOutOfBoundsException]
536536
def apply(i: Int): Long = unsafeArray(i)
537-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
537+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
538538
override def equals(that: Any) = that match {
539539
case that: ofLong => Arrays.equals(unsafeArray, that.unsafeArray)
540540
case _ => super.equals(that)
@@ -576,7 +576,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
576576
def length: Int = unsafeArray.length
577577
@throws[ArrayIndexOutOfBoundsException]
578578
def apply(i: Int): Float = unsafeArray(i)
579-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
579+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
580580
override def equals(that: Any) = that match {
581581
case that: ofFloat =>
582582
val array = unsafeArray
@@ -618,7 +618,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
618618
def length: Int = unsafeArray.length
619619
@throws[ArrayIndexOutOfBoundsException]
620620
def apply(i: Int): Double = unsafeArray(i)
621-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
621+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
622622
override def equals(that: Any) = that match {
623623
case that: ofDouble =>
624624
val array = unsafeArray
@@ -660,7 +660,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
660660
def length: Int = unsafeArray.length
661661
@throws[ArrayIndexOutOfBoundsException]
662662
def apply(i: Int): Boolean = unsafeArray(i)
663-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
663+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
664664
override def equals(that: Any) = that match {
665665
case that: ofBoolean => Arrays.equals(unsafeArray, that.unsafeArray)
666666
case _ => super.equals(that)
@@ -699,7 +699,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
699699
def length: Int = unsafeArray.length
700700
@throws[ArrayIndexOutOfBoundsException]
701701
def apply(i: Int): Unit = unsafeArray(i)
702-
override def hashCode = MurmurHash3.arraySeqHash(unsafeArray)
702+
override def hashCode() = MurmurHash3.arraySeqHash(unsafeArray)
703703
override def equals(that: Any) = that match {
704704
case that: ofUnit => unsafeArray.length == that.unsafeArray.length
705705
case _ => super.equals(that)

library/src/scala/collection/immutable/Range.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ sealed abstract class Range(
527527
super.equals(other)
528528
}
529529

530-
final override def hashCode: Int =
530+
final override def hashCode(): Int =
531531
if(length >= 2) MurmurHash3.rangeHash(start, step, lastElement)
532532
else super.hashCode
533533

library/src/scala/collection/mutable/ArraySeq.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
143143
def length: Int = array.length
144144
def apply(index: Int): T = array(index)
145145
def update(index: Int, elem: T): Unit = { array(index) = elem }
146-
override def hashCode = MurmurHash3.arraySeqHash(array)
146+
override def hashCode() = MurmurHash3.arraySeqHash(array)
147147
override def equals(that: Any) = that match {
148148
case that: ofRef[_] =>
149149
Array.equals(
@@ -166,7 +166,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
166166
def length: Int = array.length
167167
def apply(index: Int): Byte = array(index)
168168
def update(index: Int, elem: Byte): Unit = { array(index) = elem }
169-
override def hashCode = MurmurHash3.arraySeqHash(array)
169+
override def hashCode() = MurmurHash3.arraySeqHash(array)
170170
override def equals(that: Any) = that match {
171171
case that: ofByte => Arrays.equals(array, that.array)
172172
case _ => super.equals(that)
@@ -186,7 +186,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
186186
def length: Int = array.length
187187
def apply(index: Int): Short = array(index)
188188
def update(index: Int, elem: Short): Unit = { array(index) = elem }
189-
override def hashCode = MurmurHash3.arraySeqHash(array)
189+
override def hashCode() = MurmurHash3.arraySeqHash(array)
190190
override def equals(that: Any) = that match {
191191
case that: ofShort => Arrays.equals(array, that.array)
192192
case _ => super.equals(that)
@@ -206,7 +206,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
206206
def length: Int = array.length
207207
def apply(index: Int): Char = array(index)
208208
def update(index: Int, elem: Char): Unit = { array(index) = elem }
209-
override def hashCode = MurmurHash3.arraySeqHash(array)
209+
override def hashCode() = MurmurHash3.arraySeqHash(array)
210210
override def equals(that: Any) = that match {
211211
case that: ofChar => Arrays.equals(array, that.array)
212212
case _ => super.equals(that)
@@ -247,7 +247,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
247247
def length: Int = array.length
248248
def apply(index: Int): Int = array(index)
249249
def update(index: Int, elem: Int): Unit = { array(index) = elem }
250-
override def hashCode = MurmurHash3.arraySeqHash(array)
250+
override def hashCode() = MurmurHash3.arraySeqHash(array)
251251
override def equals(that: Any) = that match {
252252
case that: ofInt => Arrays.equals(array, that.array)
253253
case _ => super.equals(that)
@@ -267,7 +267,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
267267
def length: Int = array.length
268268
def apply(index: Int): Long = array(index)
269269
def update(index: Int, elem: Long): Unit = { array(index) = elem }
270-
override def hashCode = MurmurHash3.arraySeqHash(array)
270+
override def hashCode() = MurmurHash3.arraySeqHash(array)
271271
override def equals(that: Any) = that match {
272272
case that: ofLong => Arrays.equals(array, that.array)
273273
case _ => super.equals(that)
@@ -287,7 +287,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
287287
def length: Int = array.length
288288
def apply(index: Int): Float = array(index)
289289
def update(index: Int, elem: Float): Unit = { array(index) = elem }
290-
override def hashCode = MurmurHash3.arraySeqHash(array)
290+
override def hashCode() = MurmurHash3.arraySeqHash(array)
291291
override def equals(that: Any) = that match {
292292
case that: ofFloat =>
293293
val thatArray = that.array
@@ -313,7 +313,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
313313
def length: Int = array.length
314314
def apply(index: Int): Double = array(index)
315315
def update(index: Int, elem: Double): Unit = { array(index) = elem }
316-
override def hashCode = MurmurHash3.arraySeqHash(array)
316+
override def hashCode() = MurmurHash3.arraySeqHash(array)
317317
override def equals(that: Any) = that match {
318318
case that: ofDouble =>
319319
val thatArray = that.array
@@ -339,7 +339,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
339339
def length: Int = array.length
340340
def apply(index: Int): Boolean = array(index)
341341
def update(index: Int, elem: Boolean): Unit = { array(index) = elem }
342-
override def hashCode = MurmurHash3.arraySeqHash(array)
342+
override def hashCode() = MurmurHash3.arraySeqHash(array)
343343
override def equals(that: Any) = that match {
344344
case that: ofBoolean => Arrays.equals(array, that.array)
345345
case _ => super.equals(that)
@@ -356,7 +356,7 @@ object ArraySeq extends StrictOptimizedClassTagSeqFactory[ArraySeq] { self =>
356356
def length: Int = array.length
357357
def apply(index: Int): Unit = array(index)
358358
def update(index: Int, elem: Unit): Unit = { array(index) = elem }
359-
override def hashCode = MurmurHash3.arraySeqHash(array)
359+
override def hashCode() = MurmurHash3.arraySeqHash(array)
360360
override def equals(that: Any) = that match {
361361
case that: ofUnit => array.length == that.array.length
362362
case _ => super.equals(that)

library/src/scala/collection/mutable/HashMap.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,12 +578,12 @@ class HashMap[K, V](initialCapacity: Int, loadFactor: Double)
578578
@nowarn("""cat=deprecation&origin=scala\.collection\.Iterable\.stringPrefix""")
579579
override protected def stringPrefix = "HashMap"
580580

581-
override def hashCode: Int = {
581+
override def hashCode(): Int = {
582582
if (isEmpty) MurmurHash3.emptyMapHash
583583
else {
584584
val tupleHashIterator = new HashMapIterator[Any] {
585585
var hash: Int = 0
586-
override def hashCode: Int = hash
586+
override def hashCode(): Int = hash
587587
override protected def extract(nd: Node[K, V]): Any = {
588588
hash = MurmurHash3.tuple2Hash(unimproveHash(nd.hash), nd.value.##)
589589
this

library/src/scala/collection/mutable/HashSet.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,13 @@ final class HashSet[A](initialCapacity: Int, loadFactor: Double)
385385

386386
override protected def className = "HashSet"
387387

388-
override def hashCode: Int = {
388+
override def hashCode(): Int = {
389389
val setIterator = this.iterator
390390
val hashIterator: Iterator[Any] =
391391
if (setIterator.isEmpty) setIterator
392392
else new HashSetIterator[Any] {
393393
var hash: Int = 0
394-
override def hashCode: Int = hash
394+
override def hashCode(): Int = hash
395395
override protected def extract(nd: Node[A]): Any = {
396396
hash = unimproveHash(nd.hash)
397397
this

0 commit comments

Comments
 (0)