https://kotlinlang.org logo
#random
Title
# random
s

Sam

10/07/2022, 1:18 PM
If I have a value
t: T
, why does
t::class
return
KClass<out T>
and not
KClass<T>
?
Surely it’s guaranteed that
t::class
is the exact class of
t
, not a superclass?
Curiously,
t.javaClass.kotlin
does give `KClass<T>`…
The comment on StackOverflow helped me get my head around it. I was assuming that
T
is always the exact type of
t
, but really
T
could be any supertype of the actual type.