Closed
Description
This code:
object Test {
def main(args: Array[String]): Unit = {
val d: Double = null.asInstanceOf[Double]
println(d)
}
}
Is transformed both in scalac
and dotty into:
def main(args: String[]): Unit = {
val d: Double = scala.Double.unbox(null)
println(scala.Double.box(d))
}
But this is just an illusion: in scalac
, the unbox
call is actually replaced by BoxesRunTime.unboxToDouble(null)
. Dotty does not do this replacement and so the call fails with a NullPointerException
.
(I still wonder why there even is an implementation in Double.scala since it's both unused and incorrect: https://github.com/scala/scala/blob/2.11.x/src/library/scala/Double.scala#L244)
Metadata
Metadata
Assignees
Labels
No labels