Files
kotlin-fork/compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt51475.kt
T
2023-12-26 10:18:19 +00:00

27 lines
495 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// !OPT_IN: kotlin.contracts.ExperimentalContracts
// JVM_ABI_K1_K2_DIFF: KT-62464
import kotlin.contracts.*
class Smth {
val whatever: Int
init {
calculate { whatever = it }
}
context(Any)
inline fun calculate(block: (Int) -> Unit) {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
}
}
fun box(): String {
val s = Smth()
return "OK"
}