我有一堂课
class BaseApplication: @Inject constructor(protected val someType: SomeType)
和扩展类
class Application: @Inject constructor(someType: SomeType, protected val otherType:OtherType) : BaseApplication(someType)
在Application
类otherType
上的为空,直到我在BaseApplication
的ctor中声明它为止。
configure
功能:
override fun configure(binder: Binder) {
with(binder) {
bind(SomeType::class.java).toInstance(SomeType())
bind(OtherType::class.java).toInstance(OtherType())
bind(Application::class.java).asEagerSingleton()
}
}
为什么呢?