KTypeRef

class KTypeRef<T>

Wraps a KType instance with a generic type parameter, to ensure type-safe usages.

Using KType directly, we can't guarantee that the method type parameter matches the instance of KType that we get:

fun <T> doSomething(returnType: KType): T {
// ...
}

// could be misused like this
doSomething<String>(typeOf<Int>()) // mismatch String vs Int

Properties

Link copied to clipboard
val kType: KType

Sources

Link copied to clipboard