Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've just tried to reproduce your error using Scala 2.8.0 and can't. Here's my code</p> <pre><code>// Example.java public class Example { public static void test(String... args) { System.out.println(args.getClass()); } } // In test.scala object Test { def main(args: Array[String]) { test("1", "2", "3") } def test(strs: String*) = { println(strs.getClass) Example.test(strs:_*) } } </code></pre> <p>I get the following output:</p> <pre><code>class scala.collection.mutable.WrappedArray$ofRef class [Ljava.lang.String; </code></pre> <p>So it looks like the compiler is inserting the correct conversion to convert the <code>WrappedArray.ofRef</code> to a <code>String[]</code>.</p> <p><strong>Edit</strong></p> <p>Just tried running your example. It looks like some interaction of super-accessors in traits with converting Scala varargs to Java varargs. If you change the trait to a class it works.</p> <p>From the decompiled output of <code>ScalaServletModule$class</code>, it looks like it doesn't do the necessary conversion from <code>String*</code> to <code>String[]</code> when calling the super accessor (line 19).</p> <pre><code>public static void test(ScalaServletModule, java.lang.String, scala.collection.Seq); Code: 0: getstatic #11; //Field scala/Predef$.MODULE$:Lscala/Predef$; 3: aload_2 4: invokevirtual #18; //Method java/lang/Object.getClass:()Ljava/lang/Class; 7: invokevirtual #22; //Method scala/Predef$.println:(Ljava/lang/Object;)V 10: getstatic #11; //Field scala/Predef$.MODULE$:Lscala/Predef$; 13: aload_0 14: aload_1 15: aload_2 16: checkcast #24; //class "[Ljava/lang/String;" 19: invokeinterface #30, 3; //InterfaceMethod ScalaServletModule.ScalaServletModule$$super$filter:(Ljava/lang/String;[Ljava/lang/String;)Lcom/google/inject/servlet/ServletModule$FilterKeyBindingBuilder; 24: invokevirtual #22; //Method scala/Predef$.println:(Ljava/lang/Object;)V 27: return </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload