summaryrefslogtreecommitdiff
path: root/test/files/run/t1459generic
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan@lightbend.com>2017-01-12 14:46:30 -0800
committerAdriaan Moors <adriaan@lightbend.com>2017-01-24 16:35:55 -0800
commita75d3fdda25f228779ba7a6345571e6fce941197 (patch)
treec6c71e0070dc6dd11c44ac0a4136ceccbbe198ec /test/files/run/t1459generic
parentdc7ff5dd8402ea9cc1109bf729035b82c1340a51 (diff)
downloadscala-a75d3fdda25f228779ba7a6345571e6fce941197.tar.gz
scala-a75d3fdda25f228779ba7a6345571e6fce941197.tar.bz2
scala-a75d3fdda25f228779ba7a6345571e6fce941197.zip
SI-1459 two bridges for impl of java generic vararg method
A Scala method that implements a generic, Java-defined varargs method, needs two bridges: - to convert the collections for the repeated parameters (VBRIDGE) - to bridge the generics gap (BRIDGE) Refchecks emits the varargs "bridges", and erasure takes care of the other gap. Because a VBRIDGE was also an ARTIFACT, it was wrongly considered inert with respect to erasure, because `OverridingPairs` by default excluded artifacts. Removed the artifact flag from those VBRIDGES, so that they qualify for a real bridge. It would also work to include VBRIDGE methods that are artifacts in BridgesCursor.
Diffstat (limited to 'test/files/run/t1459generic')
-rw-r--r--test/files/run/t1459generic/Impl.scala4
-rw-r--r--test/files/run/t1459generic/Test.java10
-rw-r--r--test/files/run/t1459generic/VarargGeneric.java4
3 files changed, 18 insertions, 0 deletions
diff --git a/test/files/run/t1459generic/Impl.scala b/test/files/run/t1459generic/Impl.scala
new file mode 100644
index 0000000000..9234e70456
--- /dev/null
+++ b/test/files/run/t1459generic/Impl.scala
@@ -0,0 +1,4 @@
+class Impl extends VarargGeneric[String] {
+ def genericOne(x: String, arg: String): String = x + arg
+ def genericVar(x: String, args: String*): String = x + args.head
+}
diff --git a/test/files/run/t1459generic/Test.java b/test/files/run/t1459generic/Test.java
new file mode 100644
index 0000000000..a97158796b
--- /dev/null
+++ b/test/files/run/t1459generic/Test.java
@@ -0,0 +1,10 @@
+public class Test {
+ public static void main(String[] args) throws Exception {
+ VarargGeneric vg = new Impl();
+ System.out.println(vg.genericOne("a", "b"));
+ System.out.println(vg.genericVar("a", "b"));
+ // should not result in java.lang.AbstractMethodError: Impl.genericVar(Ljava/lang/Object;[Ljava/lang/String;)Ljava/lang/String;
+ // --> genericVar needs a varargs bridge (scala -> java varargs) and a standard generics bridge
+ // (for comparison, including genericOne, which needs only a generics bridge)
+ }
+}
diff --git a/test/files/run/t1459generic/VarargGeneric.java b/test/files/run/t1459generic/VarargGeneric.java
new file mode 100644
index 0000000000..c043e39b40
--- /dev/null
+++ b/test/files/run/t1459generic/VarargGeneric.java
@@ -0,0 +1,4 @@
+public interface VarargGeneric<T> {
+ String genericOne(T x, String args);
+ String genericVar(T x, String... args);
+}