23e218396e
The SAM adapter is generate on declaration site. This is different from the JVM approach. `external fun interface` is banned for now. Reusing interface declaration for the adapter is a hack which reduces code size and makes importing/exporting the adapter effortless.
26 lines
635 B
Kotlin
Vendored
26 lines
635 B
Kotlin
Vendored
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// WITH_RUNTIME
|
|
// SKIP_DCE_DRIVEN
|
|
|
|
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"
|
|
}
|