Paul Griffith
12/13/2022, 10:01 PMClass<T?>
? E.G. I need a class literal for a Double?
, so I was going to use Double::class.javaObjectType
, but I have to “unsafely” cast that to make the compiler happy. Simplified example of what I’m doing, sort of: https://pl.kotl.in/OQI60v_tVRuckus
12/13/2022, 10:45 PMClass<T?>
. Classes only exist for actual types. The fact that you can declare it is just an artifact of Java not representing nullability in its type system. That's why the Kotlin equivalent is KClass<T : Any>
.Ruckus
12/13/2022, 10:50 PMPaul Griffith
12/13/2022, 11:17 PMT::class.java
doesn’t meet the T & Any
constraint. If I make the inline fun <reified T: Any>
, it then prevents me from returning null from a getValue
lambdaPaul Griffith
12/13/2022, 11:18 PMBen Woodworth
12/13/2022, 11:25 PMKType
instead? Which you can get from typeOf<reified T>()
. That's has all the compile time type information that kotlin has, and you can get a KClass
from it if neededPaul Griffith
12/13/2022, 11:29 PMRuckus
12/14/2022, 12:05 AMPaul Griffith
12/14/2022, 12:10 AMPaul Griffith
12/14/2022, 12:10 AMRuckus
12/14/2022, 5:38 AMRuckus
12/14/2022, 5:43 AMClass<String?>
Paul Griffith
12/14/2022, 10:40 PMinline operator fun <R, reified C> invoke()
on Column, for a fake-constructor with the benefit of <reified T>
- thanks