Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'mixin' methods not generated for case objects #163

Open
raboof opened this issue Jan 30, 2019 · 0 comments
Open

'mixin' methods not generated for case objects #163

raboof opened this issue Jan 30, 2019 · 0 comments

Comments

@raboof
Copy link
Contributor

raboof commented Jan 30, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant