One way would be to use a recursive type definition like this:
interface BaseJView<TSelf : BaseJView<TSelf, P>, P : BaseJPresenter<P, TSelf>> {
fun createPresenter(): P
}
interface BaseJPresenter<TSelf : BaseJPresenter<TSelf, V>, V : BaseJView<V, TSelf>> {
fun bindView(view: V)
}
Then you can:
class Presenter : BaseJPresenter<Presenter, View> {
override fun bindView(view: View) { ... }
}
class View : BaseJView<View, Presenter> {
override fun createPresenter(): Presenter { ... }
}
source
share