Details

      Description

      === 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 SI-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

        Activity

        Hide
        Adriaan Moors added a comment -

        generalize SI-3304's fix to java varargs

        Show
        Adriaan Moors added a comment - generalize SI-3304 's fix to java varargs
        Hide
        Paul Phillips added a comment -

        I closed SI-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.

        Show
        Paul Phillips added a comment - I closed SI-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.
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/pull/478
        Show
        Jason Zaugg added a comment - https://github.com/scala/scala/commit/a21f14defaedd6ba314261bf78a0d257823c080b

          People

          • Assignee:
            Adriaan Moors
            Reporter:
            Jason Zaugg
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development