mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
26 lines
645 B
Kotlin
Vendored
26 lines
645 B
Kotlin
Vendored
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// IGNORE_BACKEND: JS, JS_IR
|
|
// WITH_RUNTIME
|
|
|
|
fun interface KRunnable {
|
|
fun invoke()
|
|
}
|
|
|
|
fun isNull(r: KRunnable?): Boolean {
|
|
if (r == null) return true
|
|
r.invoke()
|
|
return false
|
|
}
|
|
|
|
fun nullableFun(fromNull: Boolean): (() -> Unit)? =
|
|
if (fromNull) null else {{}}
|
|
|
|
fun box(): String {
|
|
if (!isNull(nullableFun(true))) return "Fail 1"
|
|
if (isNull(nullableFun(false))) return "Fail 2"
|
|
if (!isNull(null)) return "Fail 3"
|
|
if (isNull {}) return "Fail 4"
|
|
return "OK"
|
|
}
|