diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2014-07-23 09:56:24 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-07-23 10:07:13 +0200 |
commit | 926585a3f36f35c9afc3f9ed9fe0ded72f6b7014 (patch) | |
tree | 75bf522accac99be17ac4b1460e0a1e58ddaa86d /test | |
parent | 73fb460c1cd20ee97556ec0867d17efaa795d129 (diff) | |
download | scala-926585a3f36f35c9afc3f9ed9fe0ded72f6b7014.tar.gz scala-926585a3f36f35c9afc3f9ed9fe0ded72f6b7014.tar.bz2 scala-926585a3f36f35c9afc3f9ed9fe0ded72f6b7014.zip |
SI-8743 Fix crasher with poly-methods annotated with @varargs
The code that generated the Java varargs forwarder was basing
things on the `ValDef-s` of the parameters of the source method.
But, their types refer to a type parameter skolems of the enclosing
method, which led to a type mismatch when typechecking the forwarder.
Instead, I've reworked the code to simply use the `DefDef`-s symbol's
info, which *doesn't* refer to skolems. This actually simplifies the
surrounding code somewhat; rather than repeated symbols in a map
we can just time travel the pre-uncurry method signatures to figure
out which params are releated.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/jvm/varargs.check | 3 | ||||
-rw-r--r-- | test/files/jvm/varargs/JavaClass.java | 1 | ||||
-rw-r--r-- | test/files/jvm/varargs/VaClass.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t8743.scala | 15 |
4 files changed, 19 insertions, 2 deletions
diff --git a/test/files/jvm/varargs.check b/test/files/jvm/varargs.check index 8379befe93..986f98896a 100644 --- a/test/files/jvm/varargs.check +++ b/test/files/jvm/varargs.check @@ -1,3 +1,4 @@ 7 10 -19
\ No newline at end of file +19 +a diff --git a/test/files/jvm/varargs/JavaClass.java b/test/files/jvm/varargs/JavaClass.java index 9851e1b78b..6928ee5adc 100644 --- a/test/files/jvm/varargs/JavaClass.java +++ b/test/files/jvm/varargs/JavaClass.java @@ -11,5 +11,6 @@ public class JavaClass { 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 diff --git a/test/files/jvm/varargs/VaClass.scala b/test/files/jvm/varargs/VaClass.scala index 6343f9c6f6..e94e8a625a 100644 --- a/test/files/jvm/varargs/VaClass.scala +++ b/test/files/jvm/varargs/VaClass.scala @@ -9,5 +9,5 @@ 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) - + @varargs def vt1[T](a: Int, b: T*): T = b.head } diff --git a/test/files/pos/t8743.scala b/test/files/pos/t8743.scala new file mode 100644 index 0000000000..03b0cd7044 --- /dev/null +++ b/test/files/pos/t8743.scala @@ -0,0 +1,15 @@ +import annotation.varargs + +object VarArgs { + @varargs + def foo[A](x: A, xs: String*): A = ??? + + @varargs + def bar[A](x: List[A], xs: String*): A = ??? + + @varargs + def baz[A](x: List[A], xs: String*): A = ??? + + @varargs + def boz[A](x: A, xs: String*): Nothing = ??? +} |