Files
kotlin-fork/compiler/testData/codegen/box/funInterface/receiverEvaluatedOnce.kt
T
2020-01-17 19:37:48 +03:00

26 lines
466 B
Kotlin
Vendored

// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
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"
}