I'm having a problem in understanding why the following code doesn't work.
I have following project structure:
@Component(modules = CCModule.class)
public interface CComponent {
XXX getXXX();
}
where
@Module
public class CCModule {
@Provides @Singleton
public XXX provide XXX(){
return new XXX();
}
}
and
@Component(dependencies = CComponent.class, modules = AAModule.class)
public interface AComponent {
YYY getYYY();
}
where
class YYY {
@Inject
public YYY(XXX xxx) {
...
}
}
I initialize everything as:
CComponent c_component = Dagger_CComponent.builder().cCModule(new CCModule()).build();
AComponent a_component = Dagger_AComponent.builder()
.cComponent(c_component)
.aAModule(new AAModule())
.build();
Once compilation takes place i get the following error:
Error:(11, 1) error: com.test.CComponent (unscoped) may not reference scoped bindings: @Provides @Singleton com.test.XXX com.test.CCModule.provideXXX()
What I'm aiming for is to have one component inherit bindings from other components to have the same references to an objects (singletons).