With the recent versions of dagger 2 one of the improvements made are the possibility of having static provide methods. Simply so:
@Provides
static A providesA() {
return A();
}
I was wondering how does one go about doing this in kotlin? I've tried
@Module
class AModule {
companion object {
@JvmStatic
@Provides
fun providesA(): A = A()
}
}
But I get the error message:
@Provides methods can only be present within a @Module or @ProducerModule
I'm guessing there's something going on here with the companion object, however I'm quite new to Kotlin and I'm unsure of how one can do this. Is it even possible?
Thanks!