https://kotlinlang.org logo
Title
r

Ruckus

02/22/2018, 2:44 PM
It doesn't matter how you instantiate it, that function says N is a
BaseNavigator
. Unless
BaseNavigator
is a subclass of
NavigationController
(it's not, you have it the other way around), that won't compile.
y

yuriy.stetsyk

02/22/2018, 3:02 PM
Doesn't
N : BaseNavigator
states that N should inherit BaseNavigator?
r

Ruckus

02/22/2018, 4:42 PM
Yes, but your
navigation
is specifically a
NavigationController
, and you can't guarantee the
factory
passed into
f
is generic over
NavigationController
, only
BaseNavigator
.
@Andreas Sinz showed a perfect example of where that could fail (I was about to type my own here when I saw that one)
For your function to work without changing the
navigation
, you'd need something like:
fun <F, V, P> f(factory: NavigationFactory<F, V, P, NavigationController>)
        where F : Fragment,
              F : BaseView<V, P>,
              V : BaseView<V, P>,
              P : NavigatorPresenter<V, P, NavigationController>{
    factory.with(navigation)
}