Skip to content
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

Please update spec for null casting to value types #4624

Closed
scabug opened this issue May 20, 2011 · 2 comments
Closed

Please update spec for null casting to value types #4624

scabug opened this issue May 20, 2011 · 2 comments

Comments

@scabug
Copy link

scabug commented May 20, 2011

The decision was made some time back (1245, 668, 602) to support things like null.asInstanceOf[Int]. This prints 1 instead of failing:

object Main {

  def main(args: Array[String]) {
    val i: Int = null.asInstanceOf[Int]
    println(1 + i)
  }
}

Please update the spec section 6.3 which currently reads

asInstanceOf[T ] returns the "null" object itself if T conforms to
scala.AnyRef, and throws a NullPointerException otherwise.
@scabug
Copy link
Author

scabug commented May 20, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4624?orig=1
Reporter: @LilyLambda
Affected Versions: 2.9.0
See #4437

@scabug
Copy link
Author

scabug commented Jun 18, 2011

@paulp said:
Duplicate of #4437.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants