Andy Gibel
12/11/2020, 3:09 AMobject MoonWidgetInput
object MoonWidgetOutput
object MoonWidgetData
abstract class BaseVehicle<INPUT, OUTPUT>
abstract class BaseWidget<INPUT, DATA, OUTPUT>() {
abstract var vehicle : BaseVehicle<INPUT, OUTPUT>
}
class MoonRover : BaseVehicle<MoonWidgetInput, MoonWidgetOutput>()
class MoonWidget :
BaseWidget<MoonWidgetInput, MoonWidgetData, MoonWidgetOutput>(){
override var vehicle = MoonRover()
}Andy Gibel
12/11/2020, 3:11 AMvehicle override in MoonWidget is telling me that MoonRover is not a type of overriden BaseVehicle<MoonWidgetInput, MoonWidgetOutput>ephemient
12/11/2020, 3:16 AMephemient
12/11/2020, 3:17 AMabstract class BaseVehicle<in INPUT, out OUTPUT>
abstract class BaseWidget<in INPUT, DATA, out OUTPUT>
or something along those linesephemient
12/11/2020, 3:18 AM<Base> and <Derived> are unrelated. example: neither MutableList<Base> nor MutableList<Derived>` can be used in the place of the otherephemient
12/11/2020, 3:20 AM<Derived> can be used in place of <Base>. example: List<Derived> can be used in place of List<Base>ephemient
12/11/2020, 3:21 AM<Base> can be used in place of <Derived>. example: (Base) -> Unit can be used in place of (Derived) -> UnitAndy Gibel
12/11/2020, 3:23 AMBaseWidget<X,Y,Z> and derrived is a class extending that, it's THAT relationship that'd have to be covariant right?ephemient
12/11/2020, 3:47 AMBaseVehicle<in INPUT, out OUTPUT> it should workAndy Gibel
12/11/2020, 3:50 AMAndy Gibel
12/11/2020, 3:51 AMephemient
12/11/2020, 4:45 AMoverride var vehicle: BaseVehicle<MoonWidgetInput, MoonWidgetOutput> = MoonRover()ephemient
12/11/2020, 4:45 AMvar has to be invariant and without the type it's inferring it from MoonRoverAndy Gibel
12/11/2020, 2:01 PM