Files
kotlin-fork/compiler/testData/codegen/box/inlineClasses/elvisWithInlineClassAndNullConstantGeneric.kt
T
2022-02-15 08:11:13 +01:00

19 lines
408 B
Kotlin
Vendored

// WITH_STDLIB
// WORKS_WHEN_VALUE_CLASS
// LANGUAGE: +ValueClasses, +GenericInlineClassParameter
OPTIONAL_JVM_INLINE_ANNOTATION
value class UInt<T: Int>(private val data: T) {
fun result(): String = if (data == 1) "OK" else "fail"
}
fun f(): UInt<Int> {
val unull = UInt(1) ?: null
return nonNull(unull)
}
fun <T: Int> nonNull(u: UInt<T>?) = u!!
fun box(): String {
return f().result()
}