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

36 lines
735 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// WITH_COROUTINES
// JVM_ABI_K1_K2_DIFF: different order of function annotations
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
fun box(): String {
withFooBar { fooBarBaz() }
return "OK"
}
fun <T> runBlocking(c: suspend () -> T): T {
var res: T? = null
c.startCoroutine(Continuation(EmptyCoroutineContext) {
res = it.getOrThrow()
})
return res!!
}
class Foo
class Bar
class Baz
context(Foo, Bar)
fun Baz.fooBarBaz() { }
fun withFooBar(block: suspend context(Foo, Bar) Baz.() -> Unit) {
val foo = Foo()
val bar = Bar()
val baz = Baz()
runBlocking { block(foo, bar, baz) }
}