Files
kotlin-fork/compiler/testData/codegen/box/extensionFunctions/contextReceivers/kt51475.kt
T
Pavel Mikhailovskii a4bde57d44 KT-51475 Add a test
2022-12-09 15:27:59 +00:00

26 lines
463 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// !OPT_IN: kotlin.contracts.ExperimentalContracts
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"
}