hi, how do I specify the KType `java.util.UUID!`, ...
# compiler
s
hi, how do I specify the KType
java.util.UUID!
, not
java.util.UUID
nor
java.util.UUID?
? e.g. in
register<UUID?>(Arb.uuid())
s
Generally speaking that's not possible:
Platform types are non-denotable, meaning that you can't write them down explicitly in the language.
https://kotlinlang.org/docs/java-interop.html#null-safety-and-platform-types
u
You can trick the compiler into using the platform type by using a value from Java, even though it’s not denotable in pure Kotlin think smart:
Copy code
// FILE: kotlin.kt

private inline fun <reified T> typeOfValue(@Suppress("UNUSED_PARAMETER") x: T): KType =
    typeOf<T>()

fun main() {
    println(typeOfValue(Java.platformUUIDType()))  // "java.util.UUID!"
}

// FILE: Java.java

public class Java {
    public static java.util.UUID platformUUIDType() { return null; }
}