Skip to content
This repository has been archived by the owner on Aug 26, 2021. It is now read-only.

Injected types where the super class is generic causes warning messages #416

Open
sdjmchattie opened this issue Jun 23, 2014 · 1 comment

Comments

@sdjmchattie
Copy link

Where we have a class being injected which is extending a generic super type such as that shown here:

@Singleton
public class WebClient extends BaseWebClient<Void> {
    @Inject
    public WebClient() {  }
}

Compile time warnings are shown for the generated files used for injection such as those shown here:

public final class WebClient$$InjectAdapter extends Binding<WebClient>
    implements Provider<WebClient>, MembersInjector<WebClient> {
  private Binding<BaseWebClient> supertype;

  public WebClient$$InjectAdapter() {
    super("com.example.WebClient", "members/com.example..WebClient", IS_SINGLETON, WebClient.class);
  }

  /**
   * Used internally to link bindings/providers together at run time
   * according to their dependency graph.
   */
  @Override
  @SuppressWarnings("unchecked")
  public void attach(Linker linker) {
    supertype = (Binding<BaseWebClient>) linker.requestBinding("members/com.example.BaseWebClient", WebClient.class, getClass().getClassLoader(), false, true);
  }
}

Where private Binding<BaseWebClient> supertype; and supertype = (Binding<BaseWebClient>) have warnings stating:

BaseWebClient is a raw type. References to generic type BaseWebClient<Result> should be parameterized WebClient$$InjectAdapter.java
@Athou
Copy link

Athou commented Aug 17, 2014

One solution would be to annotate generated class with @SuppressWarnings("all").

tbroyer pushed a commit to tbroyer/dagger that referenced this issue Sep 3, 2016
…e42d7df308206a2f3329d0e7b8ee1fd5e2926

Sync changes via MOE from google internal
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants