New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
asInstanceOf always infers Nothing #1754
Comments
Imported From: https://issues.scala-lang.org/browse/SI-1754?orig=1 |
@odersky said: |
@paulp said: Easily summarized: scala> class Bip { def empty[T: Manifest, CC[_]] = { println(manifest[T]) ; null.asInstanceOf[CC[T]] } }
defined class Bip
scala> val x: Set[Int] = (new Bip).empty
Int
x: Set[Int] = null
scala> val x: Set[Int] = (new Bip).asInstanceOf
java.lang.ClassCastException: Bip cannot be cast to scala.runtime.Nothing$ Upon what basis should it infer Set[Int] when given nothing to go upon but the expected type, but in the same situation asInstanceOf should infer Nothing? |
@paulp said: |
The text was updated successfully, but these errors were encountered: