class A<T>(
val klass: KClass<T> // compilation error if T is not T : Any. But I can't make it T : Any, cause see test function declaration below
) {
fun test(a: T) {
if (a == null) {
println("Value is null")
} else {
// use a::class
}
}
}
How to tell compiler that KClass must use T!! while in function test T's nullable must depends on actual T's nullability?
d
dmitriy.novozhilov
11/08/2022, 2:34 PM
Copy code
class X<T>(val klass: KClass<T & Any>)
dmitriy.novozhilov
11/08/2022, 2:34 PM
Actually this question is more suitable for #getting-started
This channel is intended for discussion of compiler internals and compiler plugins at the first place
p
PHondogo
11/08/2022, 2:37 PM
Thanks for quick answer! Got it! Next question of such kind will be there.