Compiler version
Both Scala 2.13.x and Scala 3.x are affected
Minimized code
@main def test = {
println(Array.newBuilder[Int].addOne(1) == Array.newBuilder[Int].addOne(1))
println(Array.newBuilder[Int].addOne(1).hashCode == Array.newBuilder[Int].addOne(1).hashCode)
}
Output
Expectation
Details
The implementations have overridden equals, but in a wrong way, like here for ArrayBuilder.ofInt:
override def equals(other: Any): Boolean = other match {
case x: ofInt => (size == x.size) && (elems == x.elems)
case _ => false
}
Also, the hashCode implementations are missing.