KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Here are two REPL sessions (inspired by this question , although my question is different): Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0). Type in expressions to have them evaluated. Type :help for more information. scala> def ignore(it: String) = 42 ignore: (it: String)Int scala> ignore(null.asInstanceOf[Nothing]) res0: Int = 42 And: Welcome to Scala version 2.10.0 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0). Type in expressions to have them evaluated. Type :help for more information. scala> def ignore(it: String) = 42 ignore: (it: String)Int scala> ignore(null.asInstanceOf[Nothing]) java.lang.NullPointerException at .<init>(<console>:9) at .<clinit>(<console>) at .<init>(<console>:7) at .<clinit>(<console>) at $print(<console>) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ... The only difference is that the first is Scala 2.9.2 and the second is 2.10.0. Can someone point to the changes in 2.10 that lead to this new behavior? I know that casting to Nothing is a silly thing to do, and that the answer might be "this is all undefined behavior so just stop doing that", but it looks like the kind of thing that could potentially have implications for upgraders, and I don't remember running into any discussions of changes that would explain this.
Tags (comma-separated)
Save Edits
Cancel