karelpeeters
11/24/2019, 6:21 PMbar
here?
inline fun <reified A: Any?> foo() {
bar(A::class)
}
fun <B: Any> bar(cls: KClass<B>) {}
This should be possible, A::class
always returns the proper class, even if A
is nullable. It looks like the compiler doesn't realize that (I'll probably report this on youtrack). Usually I'd just cast something but I'm not sure how to do that here, I want to cast to A!!
but that's not real syntax of course. Any tricks?Alowaniak
11/24/2019, 6:38 PMbar(A::class as KClass<Any>)
?karelpeeters
11/24/2019, 6:39 PMKroppeb
11/24/2019, 7:20 PMA
anywhere in this snippet. How are you using it?karelpeeters
11/24/2019, 7:36 PMA
to be nullable in my real use case!