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

primitive arrays and java varargs #4216

Closed
scabug opened this issue Feb 5, 2011 · 5 comments
Closed

primitive arrays and java varargs #4216

scabug opened this issue Feb 5, 2011 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Feb 5, 2011

=== What steps will reproduce the problem ===

scala> def f[A: Manifest](a: A) = java.util.Arrays.asList(Array(a): _*)
f: [A](a: A)(implicit evidence$$1: Manifest[A])java.util.List[A]

scala> f("")
res0: java.util.List[java.lang.String] = []

scala> f(0)
java.lang.ClassCastException: [I cannot be cast to [Ljava.lang.Object;

=== What is the expected behavior? ===

Box primitives into an Array[Object], as per #3304 / r21981.

scala> java.util.Arrays.asList(Array(0): _*)
res17: java.util.List[Int] = r0

scala> res17.asInstanceOf[java.util.List[_ <: AnyRef]].get(0).getClass
res18: java.lang.Class[_] = class java.lang.Integer

=== What do you see instead? ===

ClassCastException

=== Additional information ===
(for instance, a link to a relevant mailing list discussion)

No probs with Scala varargs:

scala> def g[A](a: A*) = ()
g: [A](a: A*)Unit

scala> def h[A: Manifest](a: A) = g(Array(a): _*)
h: [A](a: A)(implicit evidence$$1: Manifest[A])Unit

scala> h("")

scala> h(0)

=== What versions of the following are you using? ===

  • Scala: 2.8.1, 2.9.0.r24145-b20110130020134
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Feb 5, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4216?orig=1
Reporter: @retronym
Affected Versions: 2.9.2, 2.10.0

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Feb 8, 2011

@adriaanm said:
generalize SI-3304's fix to java varargs

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jun 24, 2011

@paulp said:
I closed #750 as a duplicate of this: but it is not exactly a duplicate, so don't close this ticket without making sure that's fixed too.

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 5, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented May 6, 2012

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.