Files
kotlin-fork/compiler/testData/codegen/box/unit/nullableUnit.kt
T
Svyatoslav Kuzmich b79719d6f5 [Wasm] Fix unit issues
- Materialize unit when its value is actually needed.
- Special-case Unit_getInstance return type at codegen. It should be a
  proper Unit object instead of a "void"
2021-09-08 19:56:26 +03:00

21 lines
409 B
Kotlin
Vendored

fun isNull(x: Unit?) = x == null
fun <T : Any> isNullGeneric(x: T?) = x == null
fun deepIsNull0(x: Unit?) = isNull(x)
fun deepIsNull(x: Unit?) = deepIsNull0(x)
fun box(): String {
if (!isNull(null)) return "Fail 1"
val x: Unit? = null
if (!isNull(x)) return "Fail 2"
val y = x
if (!isNullGeneric(y)) return "Fail 3"
if (!deepIsNull(x ?: null)) return "Fail 4"
return "OK"
}