Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anvil fails to compile for Provider<T> #1043

Open
1gravity opened this issue Jul 30, 2024 · 0 comments
Open

Anvil fails to compile for Provider<T> #1043

1gravity opened this issue Jul 30, 2024 · 0 comments

Comments

@1gravity
Copy link

1gravity commented Jul 30, 2024

Thank you for fixing #1040.
While testing it I found that there's still an issue injecting Provider<T>

open class BaseClass<T : Any> {
    // this doesn't compile
    @Inject
    lateinit var provider: Provider<T>

    // this compiles
    @Inject
    lateinit var value: T
}

e: /library/build/anvil/debug/generated/com/example/library/SuperClass_Factory.kt:18:56 Unresolved reference: T
e: /library/build/anvil/debug/generated/com/example/library/SuperClass_MembersInjector.kt:22:56 Unresolved reference: T

I can inject T but not Provider<T> (we inject Provider<ViewModel> in our app). With Dagger, this compiles and runs but it doesn't if I use anvil to generate the factories.

The code can be seen in: https://github.com/1gravity/anvil-tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant