To access generic types inside a function, you need to create reified types . Since this is not supported by the JVM, it is only available in the built-in functions:
inline fun <reified T : Any> put(value: T) {
val clazz = T::class.java
}
Type restriction is Anyrequired to prevent some complications with NULL types.
source
share