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

generate .from signature for intermediate interfaces. #1119

Open
prior opened this issue Nov 5, 2019 · 0 comments
Open

generate .from signature for intermediate interfaces. #1119

prior opened this issue Nov 5, 2019 · 0 comments

Comments

@prior
Copy link

prior commented Nov 5, 2019

Given:

public interface A {
  int getAValue();
}

public interface B {
  int getBValue();
}

public interface AB extends A, B { }

@Value.Immutable
public interface ImmutableABIF extends AB { }

public class ABThing implements AB { ... }

only these from methods are generated:

  public final Builder from(B instance)
  public final Builder from(A instance)
  public final Builder from(ImmutableABIF instance)

I'd really love for

public final Builder from(AB instance)

to also be generated. I can workaround now with this:

// given an ABThing abThing;
ImmutableAB.from((A) abThing).build();

This will actually build all the fields of AB because the private from method actually checks against each possible interface with fields, but I strangely have to convert it to A (or B) to make that work. We should just offer another .from signature to handle this -- right?

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