The spec of asInstanceOf
, as written there, has been wrong for more than a decade. I haven’t gotten around to update it yet. There are much simpler cases that show how broken it is, like
val x: List[Int] = 1 :: Nil
val y: List[String] = x.asInstanceOf[List[Int]] // "succeeds", against the spec