A question about reified type parameters. ```inli...
# announcements
m
A question about reified type parameters.
Copy code
inline fun <reified T> test(): Unit {
    println(T::class.java.typeParameters.joinToString(separator = ","))
    println(T::class)
}

fun main() {
    test<Either<ReferenceObject, SchemaObject>>()
}
Is there a way I can retain
ReferenceObject
,
SchemaObject
? It looks like reified is not recursive...
r
if you always want to do something on
Either<K, V>
you can just do reified K & V, and write
Either<K, V>
everywhere instead of
T
(Ofc, this will force the function to always work with
Either
)
e
Copy code
import kotlin.reflect.typeOf
inline fun <reified T>  test() {
    println(typeOf<T>().arguments.joinToString())
    println(typeOf<T>().classifier)
}