diff options
author | Lukas Rytz <lukas.rytz@gmail.com> | 2016-11-16 11:25:20 +0100 |
---|---|---|
committer | Lukas Rytz <lukas.rytz@gmail.com> | 2016-11-16 11:31:20 +0100 |
commit | cc3bd35d024524f697907dd7a68fde22420407eb (patch) | |
tree | acf68bc529426765ca2beb2379a7447257c53815 /test | |
parent | 10c609e750a7089055b126e6231e5ddb2f2e8623 (diff) | |
download | scala-cc3bd35d024524f697907dd7a68fde22420407eb.tar.gz scala-cc3bd35d024524f697907dd7a68fde22420407eb.tar.bz2 scala-cc3bd35d024524f697907dd7a68fde22420407eb.zip |
SI-10059 reset the `DEFERRED` flag for Java varargs forwarders
When an abstract method is annotated `@varargs`, make sure that the
generated synthetic Java varargs method does not have the `DEFERRED`
flag (`ACC_ABSTRACT` in bytecode).
The flag lead to an NPE in the code generator, because the ASM framework
leaves certain fields `null` for abstract methods (`localVariables` in
this case).
Interestingly this did not crash in 2.11.x: the reason is that the test
whether to emit a method body or not has changed in the 2.12 backend
(in c8e6050).
val isAbstractMethod = [..] methSymbol.isDeferred [..] // 2.11
val isAbstractMethod = rhs == EmptyTree // 2.12
So in 2.11, the varargs forwarder method was actually left abstract in
bytecode, leading to an `AbstractMethodError: T.m([I)I` at run-time.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t10059/A.java | 3 | ||||
-rw-r--r-- | test/files/run/t10059/Test.scala | 9 |
2 files changed, 12 insertions, 0 deletions
diff --git a/test/files/run/t10059/A.java b/test/files/run/t10059/A.java new file mode 100644 index 0000000000..49b6447817 --- /dev/null +++ b/test/files/run/t10059/A.java @@ -0,0 +1,3 @@ +public class A { + public static int foo(T t) { return t.m(1, 2, 3); } +} diff --git a/test/files/run/t10059/Test.scala b/test/files/run/t10059/Test.scala new file mode 100644 index 0000000000..7bbb623e74 --- /dev/null +++ b/test/files/run/t10059/Test.scala @@ -0,0 +1,9 @@ +abstract class T { + @annotation.varargs def m(l: Int*): Int +} +class C extends T { + override def m(l: Int*): Int = 1 +} +object Test extends App { + assert(A.foo(new C) == 1) +} |