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.
25 lines
436 B
Kotlin
Vendored
25 lines
436 B
Kotlin
Vendored
// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
|
|
// IGNORE_BACKEND_FIR: JVM_IR
|
|
// WITH_RUNTIME
|
|
// SKIP_DCE_DRIVEN
|
|
|
|
fun interface KRunnable {
|
|
fun invoke()
|
|
}
|
|
|
|
fun runTwice(r: KRunnable) {
|
|
r.invoke()
|
|
r.invoke()
|
|
}
|
|
|
|
class A() {
|
|
fun f() {}
|
|
}
|
|
|
|
fun box(): String {
|
|
var x = 0
|
|
runTwice({ x++; A() }()::f)
|
|
if (x != 1) return "Fail"
|
|
return "OK"
|
|
}
|