Skip to content

Unable to inject @JvmInline value classes #2930

Open
@drinkthestars

Description

@drinkthestars

Injecting a @JvmInline value class fails in the following manner:

Code:

@JvmInline value class Foo(val value: Int)

@Module
@InstallIn(SingletonComponent::class)
object FooModule {
    @Provides
    fun provideFoo() = Foo(value = 123)
}

class FooBar @Inject constructor(
    private val foo: Foo
) { /** ... **/ }

class UsesFooBar @Inject constructor(
    private val fooBar: FooBar
) { /** Uses fooBar **/ }

Fails with:

[Dagger/MissingBinding] FooBar cannot be provided without an @Inject constructor or an @Provides-annotated method.
  public abstract static class SingletonC implements FooApplication_GeneratedInjector

Not sure if this is a bug, or if it's just impossible to support with kapt (i.e. needs something like KSP) 🤔. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions