Issa
03/03/2021, 10:14 AMimport kotlin.reflect.KClass
fun main() {
doSomething(B::class, C::class)
}
fun <T : A> doSomething(vararg dialogClasses: KClass<T>) {
// no-op
}
open class A
class B : A()
class C : A()
the compiler complains about the second argument of doSomething()
function even if it is a sub-type of A
. Is there any reason for this complaint?
How can this issue can be solved?ti4n
03/03/2021, 10:18 AMfun doSomething(vararg dialogClasses: KClass<out A>) {
// no-op
}
try thisIssa
03/03/2021, 10:28 AMAsagald
03/03/2021, 10:32 AMWilly Ricardo
03/03/2021, 1:23 PMdoSomething<A>(B::class, C::class)
gabrielfv
03/03/2021, 9:59 PMfun <T : A> doSomething(...)
is different from fun doSomething(... KClass<out A>)
. But yeah, in this scenario it seems pretty clear @ti4n suggestion is the desired behavior