pawel.urban
09/12/2018, 11:38 AMfun doSomething(input: SomeClass<Concrete?>)
.
Use case is:
val localInstance: SomeClass<Concrete> = ...
doSomething(localInstance)
Should I naively cast local instance to localInstance as SomeClass<Concrete?>
to use this method? Assume that I can’t change the method.marstran
09/12/2018, 11:43 AMSomeClass
? It works if you make its type parameter covariant. class SomeClass<out T>
SomeClass<Concrete>
a subtype of SomeClass<Concrete?>
.pawel.urban
09/12/2018, 11:50 AMLiveData
in this case.diesieben07
09/12/2018, 11:52 AMdoSomething
) might be trying to put a null
into your SomeClass
. If you were to pass in a SomeClass<Concrete>
that would cause problems.pawel.urban
09/12/2018, 11:55 AMmarstran
09/12/2018, 11:56 AMfun doSomething(input: SomeClass<out Concrete?>)