-
Notifications
You must be signed in to change notification settings - Fork 21
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
Return type inference doesn't affect Manifest #2609
Comments
Imported From: https://issues.scala-lang.org/browse/SI-2609?orig=1 |
@jorgeortiz85 said: |
@harrah said: scala> val s: String = null.asInstanceOf[Nothing]
s: String = null Of course, Nothing is not supposed to have any instances, so having an actual instance assigned to a val of type Nothing is presumably the cause of the following: scala> val s = null.asInstanceOf[Nothing]
java.lang.NullPointerException
at RequestResult$$.<init>(<console>:9)
at RequestResult$$.<clinit>(<console>)
at RequestResult$$result(<console>)
... |
@odersky said: |
@adriaanm said (edited on Jul 8, 2011 9:31:43 AM UTC): object Test extends App {
def inject0[T]: T = null.asInstanceOf[T]
def m0: String = inject0 // inject0[Nothing] is inferred
def inject1[T](implicit m: Manifest[T]): T = {println(m.toString); null.asInstanceOf[T]}
def m1: String = inject1 // inject1[Nothing] is inferred
class M[T]; implicit def M[T] = new M[T]
def inject2[T](implicit m: M[T]): T = {println(m.toString); null.asInstanceOf[T]}
def m2: String = inject2 // inject2[Nothing] is inferred
m0
m1
m2
} |
What I see:
I would expect the second manifest to be java.lang.String, since the type T is correctly inferred to be T.
The text was updated successfully, but these errors were encountered: