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
Scala tries to pass primitive arrays to Java methods expecting polymorphic array types #750
Comments
Imported From: https://issues.scala-lang.org/browse/SI-750?orig=1 |
@odersky said: |
@odersky said: |
@paulp said: [paulp@leaf 750]$$ scalac AO.java a.scala
[paulp@leaf 750]$$ scala Main
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;
at Main$$.main(a.scala:4)
at Main.main(a.scala) But: [paulp@leaf 750]$$ javac AO.java
[paulp@leaf 750]$$ scalac a.scala
a.scala:4: error: type mismatch;
found : Array[Int]
required: Array[? with java.lang.Object]
AO.f(a)
^
one error found |
@retronym said: |
Spotted by Amit Dev
Java:
Scala:
This tries to cast
a
toObject[]
, which will always fail. It should give a compile-time error, since Java doesn't support polymorphic use of primitive arrays.The text was updated successfully, but these errors were encountered: