阅读相同的文章后,我仍然无法解决泛型问题:
我有基本活动:
abstract class BaseActivity : MvpAppCompatActivity(), BaseView {
abstract fun getPresenter():BasePresenter<BaseView>
}
BaseView 接口
interface BaseView : MvpView
并且肯定 BasePresenter
open class BasePresenter<T : BaseView> : MvpPresenter<T>()
然后我创建 BaseConnectionView
interface BaseConnectionView : BaseView
和 BaseConnectionPresenter
class BaseConnectionPresenter<T : BaseConnectionView> : BasePresenter<T>()
所以当我创建 BaseConnectionActivity
abstract class BaseConnectionActivity : BaseActivity(),BaseConnectionView {
override abstract fun getPresenter(): BaseConnectionPresenter<BaseConnectionView>
}
我有错误:
Return type is BaseConnectionPresenter<BaseConnectionView>,
which is not a subtype of overridden
public abstract fun getPresenter():BasePresenter<BaseView>
但它是亚型!
我怎么解决这个问题?