Skip to content

AbstractMethodError when implementing abstract @varargs method #9013

@scabug

Description

@scabug
import scala.annotation.varargs abstract class VarargAbstractClass { @varargs def x(els: String*): Int } class ClassImplementsClass extends VarargAbstractClass { override def x(els: String*): Int = els.length }

fails with an AbstractMethodError when the method is called from Java like this:

VarargAbstractClass i = new ClassImplementsClass(); i.x("a", "b", "c");

See more examples in this file:

https://github.com/jrudolph/scala-broken-java-varargs/blob/master/src/test/java/example/Test.java

I first thought that this was related to #1459 but I know think it is a separate issue. It seems the main problem is that the forwarder in VarargAbstractClass is created as abstract because in Uncurry flags from the original method are just copied to the forwarder method. Clearing the DEFERRED flag for the forwarder method seems to fix this issue for me (but I didn't run the complete test suite to look for other problems).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions