object Test {
def main(args: Array[String]): Unit = {
val x: Any = 66
val y: Any = 66.toByte
println(x == y)
}
}
This should print true, but prints false at the moment.
You need to call BoxesRunTime.equals when translating an == primitive in the scalac back-end.
Yep, currently we mistakingly just call java.lang.Object.equals instead. It obviously doesn't support cooperative equality between primitive boxes.
Well in fact, in the case of SN, you could actually change Integer.equals and friends so that they do support cooperative equality. That would help SN with the bad == performance of Scala. But you will have to trade some of the semantics of Object.equals for that.
Alternatively, we can also add a new virtual method (e.g. java.lang.Object.==) that behaves like cooperative Scala equality from BoxesRunTime.equals and is overridden for all box types without touching java.lang.Object.equals. Win-win. 馃憦