diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2017-01-12 14:46:30 -0800 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2017-01-24 16:35:55 -0800 |
commit | a75d3fdda25f228779ba7a6345571e6fce941197 (patch) | |
tree | c6c71e0070dc6dd11c44ac0a4136ceccbbe198ec /test | |
parent | dc7ff5dd8402ea9cc1109bf729035b82c1340a51 (diff) | |
download | scala-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')
-rw-r--r-- | test/files/run/t1459generic.check | 2 | ||||
-rw-r--r-- | test/files/run/t1459generic/Impl.scala | 4 | ||||
-rw-r--r-- | test/files/run/t1459generic/Test.java | 10 | ||||
-rw-r--r-- | test/files/run/t1459generic/VarargGeneric.java | 4 |
4 files changed, 20 insertions, 0 deletions
diff --git a/test/files/run/t1459generic.check b/test/files/run/t1459generic.check new file mode 100644 index 0000000000..367ac87ad1 --- /dev/null +++ b/test/files/run/t1459generic.check @@ -0,0 +1,2 @@ +ab +ab 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); +} |