interface BaseComponent {
fun factory(): Factory
interface Factory {
fun create(@BindsInstance int: Int): BaseComponent
}
}
@Subcomponent
interface SomeComponent : BaseComponent {
override fun factory(): SomeComponent.Factory
@Subcomponent.Factory
interface Factory : BaseComponent.Factory {
override fun create(@BindsInstance int: Int): SomeComponent
}
}
Notice how I override all the base classes to the concrete types.
Changing the Factory to a Builder doesn't work and I don't see a reason why Dagger shouldn't support it:
interface BaseComponent {
fun builder(): Builder
interface Builder {
@BindsInstance fun charSequence(sequence: CharSequence): Builder
fun build(): BaseComponent
}
}
@Subcomponent
interface SomeComponent : BaseComponent {
override fun builder(): SomeComponent.Builder
@Subcomponent.Builder
interface Builder : BaseComponent.Builder {
@BindsInstance override fun charSequence(sequence: CharSequence): SomeComponent.Builder
override fun build(): SomeComponent
}
}
Dagger throws several different errors depending on other changes. The first I run into is:
[Dagger/MissingBinding] java.lang.CharSequence cannot be provided without an @Provides-annotated method.
After stopping to rely on the binding I see this error:
DaggerParentComponent.SomeComponentBuilder is not abstract and does not override abstract method charSequence(CharSequence) in Builder
private final class SomeComponentBuilder implements SomeComponent.Builder {
This example for factories compiles fine:
Notice how I override all the base classes to the concrete types.
Changing the Factory to a Builder doesn't work and I don't see a reason why Dagger shouldn't support it:
Dagger throws several different errors depending on other changes. The first I run into is:
After stopping to rely on the binding I see this error: