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();
}
我想知道在Kotlin 怎么做?我试过了
@Module
class AModule {
companion object {
@JvmStatic
@Provides
fun providesA(): A = A()
}
}
但我得到了错误信息:
@Provides methods can only be present within a @Module or @ProducerModule
我猜伴星物体在这里发生了一些事情,但是我对Kotlin 很陌生,我不确定如何做到这一点.有可能吗?
Thanks!