Files
kotlin-fork/compiler/testData/codegen/box/funInterface/receiverEvaluatedOnce.kt
T
2021-10-08 07:24:41 +03:00

23 lines
387 B
Kotlin
Vendored

// !LANGUAGE: +NewInference +FunctionalInterfaceConversion +SamConversionPerArgument +SamConversionForKotlinFunctions
// 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"
}