Files
kotlin-fork/compiler/testData/codegen/box/extensionFunctions/contextReceivers/suspendContextualWithExtension.kt
T
2022-04-06 16:05:39 +00:00

38 lines
611 B
Kotlin
Vendored

// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// WITH_COROUTINES
// WITH_STDLIB
import helpers.*
import kotlin.coroutines.*
import kotlin.coroutines.intrinsics.*
class Context {
fun c() = "O"
}
class Extension {
fun e() = "K"
}
context(Context)
suspend fun Extension.suspendingTest() = c() + e()
fun builder(c: suspend () -> Unit) {
c.startCoroutine(EmptyContinuation)
}
fun box(): String {
var result = "fail"
builder {
with(Extension()) {
with(Context()) {
result = suspendingTest()
}
}
}
return result
}