Skip to content

Anvil fails to compile for Provider<T> #1043

Open
@1gravity

Description

@1gravity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions