From 0d2760dce189cdcb363e54868381175af4b2646f Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 5 Jul 2016 14:22:00 +0200 Subject: SI-8786 fix generic signature for @varargs forwarder methods When generating a varargs forwarder for def foo[T](a: T*) the parameter type of the forwarder needs to be Array[Object]. If we gnerate Array[T] in UnCurry, that would be erased to plain Object, and the method would not be a valid varargs. Unfortunately, setting the parameter type to Array[Object] lead to an invalid generic signature - the generic signature should reflect the real signature. This change adds an attachment to the parameter symbol in the varargs forwarder method and special-cases signature generation. Also cleanes up the code to produce the varargs forwarder. For example, type parameter and parameter symbols in the forwarder's method type were not clones, but the same symbols from the original method were re-used. --- test/files/jvm/varargs/JavaClass.java | 26 +++++++++++--------------- test/files/jvm/varargs/VaClass.scala | 9 +-------- test/files/jvm/varargs/varargs.scala | 16 ---------------- 3 files changed, 12 insertions(+), 39 deletions(-) (limited to 'test/files/jvm/varargs') diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java index 6928ee5adc..0cc3587c5e 100644 --- a/test/files/jvm/varargs/JavaClass.java +++ b/test/files/jvm/varargs/JavaClass.java @@ -1,16 +1,12 @@ - - - public class JavaClass { - public static void varargz(int i, T... v) { - } - - public static void callSomeAnnotations() { - VaClass va = new VaClass(); - va.vs(4, "", "", ""); - va.vi(1, 2, 3, 4); - varargz(5, 1.0, 2.0, 3.0); - va.vt(16, "", "", ""); - System.out.println(va.vt1(16, "a", "b", "c")); - } -} \ No newline at end of file + public static void varargz(int i, T... v) { } + + public static void callSomeAnnotations() { + VaClass va = new VaClass(); + va.vs(4, "", "", ""); + va.vi(1, 2, 3, 4); + varargz(5, 1.0, 2.0, 3.0); + va.vt(16, "", "", ""); + System.out.println(va.vt1(16, "a", "b", "c")); + } +} diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala index d83e63ace1..ee8c288a16 100644 --- a/test/files/jvm/varargs/VaClass.scala +++ b/test/files/jvm/varargs/VaClass.scala @@ -1,15 +1,8 @@ - - import annotation.varargs - - class VaClass { - @varargs def vs(a: Int, b: String*) = println(a + b.length) @varargs def vi(a: Int, b: Int*) = println(a + b.sum) @varargs def vt[T](a: Int, b: T*) = println(a + b.length) - - // TODO remove type bound after fixing SI-8786, see also https://github.com/scala/scala/pull/3961 - @varargs def vt1[T <: String](a: Int, b: T*): T = b.head + @varargs def vt1[T](a: Int, b: T*): T = b.head } diff --git a/test/files/jvm/varargs/varargs.scala b/test/files/jvm/varargs/varargs.scala index 6d2e707bdf..b09818f46f 100644 --- a/test/files/jvm/varargs/varargs.scala +++ b/test/files/jvm/varargs/varargs.scala @@ -1,21 +1,5 @@ - - - - - - object Test { def main(args: Array[String]) { JavaClass.callSomeAnnotations } } - - - - - - - - - - -- cgit v1.2.3