dagger-reflect icon indicating copy to clipboard operation
dagger-reflect copied to clipboard

`@Provides` within a `companion object` not being injected

Open johncara opened this issue 4 years ago • 2 comments

If I try to provide an object using the following code; Dagger works, but Reflect doesn't:

@Module
interface MyModule {

    companion object {
        @Provides
        fun providesString(): String = "Hello"
    }
}

Same is true if MyModule is a class or an abstract class.

Perhaps this is covered by what's described in this limitation? https://github.com/JakeWharton/dagger-reflect#abstract-classes

johncara avatar Apr 22 '21 11:04 johncara

This seems related to https://github.com/JakeWharton/dagger-reflect/issues/185.

You can add @JvmStatic to providesString in the meanwhile for dagger reflect to work.

BenSchwab avatar Apr 23 '21 16:04 BenSchwab

Looks like the same thing alright, thanks for the link and workaround.

johncara avatar Apr 26 '21 09:04 johncara