Dagger 2 BindsInstance не поддерживается для ChildComponent, который связан через ParentComponent? - PullRequest
0 голосов
/ 28 октября 2019

У нас может быть либо

@Subcomponent(modules = [XModule::class, YModule::class])
interface ChildComponent

@Singleton
@Component
interface ParentComponent {
    fun childComponent(x: XModule, y: YModule): ChildComponent
}

, либо

@Subcomponent(modules = [XModule::class, YModule::class])
interface ChildComponent {
    @Subcomponent.Builder
    interface Builder {
        fun xModule(x: XModule): Builder
        fun yModule(y: YModule): Builder
        fun build(): RequestComponent
    }
}

@Singleton
@Component
interface ParentComponent {
    fun childComponentBuilder: ChildComponentBuilder
}

Однако, мы можем иметь

@Subcomponent
interface ChildComponent {
    @Subcomponent.Builder
    interface Builder {
        fun data(@BindsInstance data: Data): Builder
        fun build(): RequestComponent
    }
}

@Singleton
@Component
interface ParentComponent {
    fun childComponentBuilder: ChildComponentBuilder
}

Но не

@Subcomponent
interface ChildComponent

@Singleton
@Component
interface ParentComponent {
    fun childComponent(@BindsInstance data: Data): ChildComponent
}

Это жалобы

error: Subcomponent factory methods may only accept modules, but com.elyeproj.daggertwomultibindings.subcomponentthroughcomponent.Data is not.
    com.elyeproj.daggertwomultibindings.subcomponentthroughcomponent.Data data, @org.jetbrains.annotations.NotNull()
                                                                          ^ 

Я думал, что эта поддержка уже осуществляется через https://github.com/google/dagger/issues/616?

...