[Dagger/Nullable] issue when using generic type in subcomponent factory #65
-
Hi Zac, We've migrated successfully from Anvil to your fork (KSP only), there was one change required and it looks like a bug of Essentially, subcomponent factories don't allow generic without explicitly extending Any, although the type is nonnull in the use case. interface AnvilAndroidInjector<T> {
val injector: MembersInjector<T>
fun inject(target: T) {
injector.injectMembers(target)
}
interface Factory<T> {
fun create(@BindsInstance instance: T): AnvilAndroidInjector<T>
}
}
@MergeSubcomponent(scope = MainActivity::class)
interface MainActivitySubcomponent : AnvilAndroidInjector<MainActivity> {
@MergeSubcomponent.Factory
interface Factory : AnvilAndroidInjector.Factory<MainActivity>
} I created a small project to replicate our DI mechanism with minimal code, and prepared a PR to demo the issue we're facing, hope it will help. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This appears to just be coming from dagger itself. Is the request to duplicate this check in Anvil-KSP too? |
Beta Was this translation helpful? Give feedback.
No, I'm just wondering why it complains about passing null to the factory method while the input isn't nullable. I guess it's required for dagger KSP now, thanks for the reply!