'mixin' methods not generated for case objects
raboof opened this issue · comments
When a method is defined in a trait (i.e. TraitWithMethod
), and that trait is mixed into an object (i.e. MethodFromTrait
:
trait TraitWithMethod {
def theMethod(): Int = 42
}
case object MethodFromTrait extends TraitWithMethod {
def foo(): Unit = ???
}
Then this should lead to 3 class files: the trait is converted to an interface declaring the method:
public interface TraitWithMethod {
public static int theMethod$(TraitWithMethod);
public int theMethod();
public static void $init$(TraitWithMethod);
}
The MethodFromTrait$
class that implements the interface and contains the method implementation:
public final class MethodFromTrait$ implements TraitWithMethod {
public static MethodFromTrait$ MODULE$;
public static {};
public int theMethod();
public void foo();
}
And a MethodFromTrait
class with static forwarders:
public final class MethodFromTrait$ implements TraitWithMethod {
public static MethodFromTrait$ MODULE$;
public static {};
public int theMethod();
public void foo();
}
Currently, genjavadoc does not generate the method on MethodFromTrait$
, because genjavadoc runs after the fields
compiler stage, and the method is generated later in the mixin
stage.
We could fix this by either running genjavadoc after a later compiler stage (but this potentially means undoing a lot of the work in those phases, or simulating the mixin
stage logic in genjavadoc.