Я реализую архитектуру MVP в Kotlin
, и Android Studio не показывает ошибок, однако не компилируется:
java.lang.AssertionError: resultDescriptor не должен быть нулевым:андидат: дескриптор: конструктор BasePresenter (представление: представление), определенный в замене com.exmaple.base.BasePresenter: org.jetbrains.kotlin.types.IndexedParametersSubstitution@70144d7e в org.jetbrains.kotlin.resolve.calls.model.mpesIllImpIllImpIllRec.java: 205) ....
Можно ли использовать ConcreteView
/ ConcretePresenter
в середине наследования?
код:
/**
* These are the base classes
*/
interface MvpView
interface BaseView<Presenter : BasePresenter<*>> : MvpView, HasMvpView<MvpView>
// to avoid circular dependency
interface HasMvpView<View : MvpView>
abstract class BaseMvpActivity<Presenter : BasePresenter<*>> : AppCompatActivity(), HasMvpView<MvpView>
abstract class BaseMvpFragment<Activity : BaseMvpActivity<*>, Presenter : BasePresenter<*>>: Fragment(), HasMvpView<MvpView> {
// this will cause the error
abstract var presenter: Presenter
}
/**
* There's a Viewpager, and each page looks the same the only difference is their source of data. That's why I tried implementing another level of abstraction over the base classes
*/
interface CategoryPagerView<Presenter: BasePresenter<*>> : BaseView<Presenter>
abstract class CategoryPagerFragment: BaseMvpFragment<LandingActivity, BasePresenter<*>>()
/**
* A concrete type of the Viewpager's fragment, its presenter and the view
*/
interface ConcreteView : CategoryPagerView<ConcretePresenter>
class ConcretePresenter(view: ConcreteView) : BasePresenter<*>(view)
class ConcreteFragment : CategoryPagerFragment(), ConcreteView {
// this line shows no error in the IDE, but in compile time
override var presenter = ConcretePresenter(this)
Спасибо за помощь!