Is there any way to call `bar` here? ```inline fu...
# announcements
k
Is there any way to call
bar
here?
Copy code
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?
a
Can't you do
bar(A::class as KClass<Any>)
?
k
Hmm that does work, but then I completely lose all type information and I need to cast the result back as well.
k
You aren't using the nullability of
A
anywhere in this snippet. How are you using it?
☝🏼 3
k
Huh it turns out I indeed do not need
A
to be nullable in my real use case!