Skip to content

Instantly share code, notes, and snippets.

@adennie
Created March 19, 2013 19:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adennie/5199473 to your computer and use it in GitHub Desktop.
Save adennie/5199473 to your computer and use it in GitHub Desktop.
inherited qualified provider not found when checking for completeness of bindings
package com.fizzbuzz.daggerexperiments;
import dagger.Module;
import dagger.Provides;
import javax.inject.Inject;
import javax.inject.Qualifier;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
public class ContextHoldingModules2 {
public static void main(String[] args) {
}
@Qualifier
@Target({FIELD, PARAMETER, METHOD})
@Documented
@Retention(RUNTIME)
public @interface Application {
}
public static class Context {
}
public static class HasInjectedContext {
@Inject @Application
Context mContext;
}
@Module
public static class BaseModule {
private Context mContext;
public BaseModule(Context context) {
mContext = context;
}
@Provides
@Application
public Context provideContext() {
return mContext;
}
}
@Module (entryPoints = {Context.class, HasInjectedContext.class})
public static class DerivedModule
extends BaseModule{
public DerivedModule() {
super(new Context());
}
}
}
@adennie
Copy link
Author

adennie commented Mar 19, 2013

ContextHoldingModules2.java:[51,18] No binding for @com.fizzbuzz.daggerexperiments.ContextHoldingModules2$Application()/com.fizzbuzz.daggerexperiments.ContextHoldingModules2$Context required by com.fizzbuzz.daggerexperiments.ContextHoldingModules2.HasInjectedContext for com.fizzbuzz.daggerexperiments.ContextHoldingModules2.DerivedModule

@swankjesse
Copy link

Hmmm . . . I'm tempted to forbid subclassing modules altogether. Composition instead of inheritance, right?

@adennie
Copy link
Author

adennie commented Mar 23, 2013

Well, if you're referring to something like ObjectGraph.create(new MyAppModule(), new AppModule(new Context())), where AppModule has the Context provider, that might work. I'll try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment