Marc Knaup
10/24/2017, 8:58 PMKType
which is exactly the thing I need!
Now I’d love to get a KType
from a reified generic argument 🙂
I found this, but it uses reflection since there is no other way:
https://gist.github.com/udalov/bb6f398c2e643ee69586356fdd67e9b1
So my suggestion is to add SomeClass::type
to get it’s KType
instead of KClass
. It’s only available when the type is known at compile-time - as it is with reified
.
inline fun <reified T> test() {
println("Type is ${T::type}")
}
test<List<String>>() // prints "Type is kotlin.collections.List<kotlin.String>"