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

value class tree rewriting creates ClassCastException #6786

Closed
scabug opened this issue Dec 7, 2012 · 2 comments
Closed

value class tree rewriting creates ClassCastException #6786

scabug opened this issue Dec 7, 2012 · 2 comments
Milestone

Comments

@scabug
Copy link

scabug commented Dec 7, 2012

class Foo(val x: Int) extends AnyVal

object Test {
  def main(args: Array[String]): Unit = {
    // This works, prints "Foo@5"
    val x = new Foo(5) ; println(x.asInstanceOf[Object])
    // ClassCastException
    println((new Foo(5)).asInstanceOf[Object])
  }
}
/****

java.lang.ClassCastException: Foo cannot be cast to java.lang.Integer
  at scala.runtime.BoxesRunTime.unboxToInt(Unknown Source)
  at Test$.main(a.scala:5)
  at Test.main(a.scala)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:601)
  at scala.tools.nsc.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:68)
  at scala.tools.nsc.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
  at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:99)
  at scala.tools.nsc.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:68)
  at scala.tools.nsc.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:99)
  at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
  at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)

  ****/
@scabug
Copy link
Author

scabug commented Dec 7, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6786?orig=1
Reporter: @paulp
Affected Versions: 2.11.0-M1

@scabug scabug added this to the Backlog milestone Apr 7, 2017
@som-snytt
Copy link

Works since 2.12. Testing 2.11 is a hassle.

@SethTisue SethTisue modified the milestones: Backlog, 2.12.0 Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants