From cc3bd35d024524f697907dd7a68fde22420407eb Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Wed, 16 Nov 2016 11:25:20 +0100 Subject: 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. --- test/files/run/t10059/Test.scala | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 test/files/run/t10059/Test.scala (limited to 'test/files/run/t10059/Test.scala') 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) +} -- cgit v1.2.3