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

@Provides within a companion object not being injected #218

Open
johncara opened this issue Apr 22, 2021 · 2 comments
Open

@Provides within a companion object not being injected #218

johncara opened this issue Apr 22, 2021 · 2 comments

Comments

@johncara
Copy link

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

@BenSchwab
Copy link

This seems related to #185.

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

@johncara
Copy link
Author

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

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

2 participants