anvil
anvil copied to clipboard
[dagger-factory] Member injection for super types fails when passing a generic type and using constructor injection
Hi, I'm facing an issue similar to https://github.com/square/anvil/issues/486 but instead of using field injection in the InjectClass
, we use constructor injection. Following is the sample to reproduce the issue:
package com.sample.anvil
import javax.inject.Inject
abstract class Base<S> {
@Inject
lateinit var strings: List<S>
}
package com.sample.anvil
import javax.inject.Inject
class InjectClass @Inject constructor() : Base<String>() {}
The MemberInjector generated for InjectClass throws compilation error with the message Unresolved reference: S.
Anvil generates:
public class InjectClass_Factory(
private val strings: List<@JvmSuppressWildcards VM>,
) : Factory<InjectClass> {
...
and Dagger generates:
public final class InjectClass_Factory implements Factory<InjectClass> {
private final List<String> strings;
public InjectClass_Factory(List<String> strings) {
this.strings = strings;
}
...
seeing the same for classes that extend an abstract class, the members injector generated also uses generics:
abstract class SomeFragment<P> {
@set:Inject
var presenterLazy: Lazy<P>? = null
}
extend:
class SomeFragmentSubclass : SomeFragment<SomePresenter>
generates :
public class SomeFragmentSubclass_MembersInjector(
private val presenterLazy: Provider<@JvmSuppressWildcards P>,
) : MembersInjector<SomeFragmentSubclass> {
What does the generated dagger code for SomeFragmentSubclass_MembersInjector
or InjectClass_MembersInjector
look like?