You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Worth adding this was a good one. Earlier I checked List[3.14](3.14, 3). I also checked in the example that 3.0 is stored in the field, but I didn't check what REPL is reporting when it prints the RHS. I also wondered whether it matters what is stored in the field.
No one would complain about
scala> var x: 3.14 = null.asInstanceOf[3.14]
var x: 3.14 = 0.0
oh wait
scala> x
val res1: Double = 0.0
which I guess is due to unstable x but still surprises me. x has to be 3.14 even if I lied in initializing it.
Scala 2 throws in the isInstanceOf case. I don't know why without consulting code or spec.
scala> trait T { inline val pi = 3.14 }
// defined trait T
scala> (null: T).pi
val res0: Double = 3.14
scala> null.asInstanceOf[T].pi
1 |null.asInstanceOf[T].pi
|^^^^^^^^^^^^^^^^^^^^^^^
|getter pi is declared as erased, but is in fact used
Compiler version
3.0.0-RC3
Minimized code
Expectation
2.13.4
The text was updated successfully, but these errors were encountered: