KT-53551 KT-52213 KT-58476 Fix handling of suspend functional types with context receivers

This commit is contained in:
strangepleasures
2023-09-07 12:40:01 +00:00
committed by Space Team
parent c2ee9bb1a4
commit 88453a05f1
10 changed files with 184 additions and 1 deletions
@@ -0,0 +1,35 @@
// !LANGUAGE: +ContextReceivers
// TARGET_BACKEND: JVM_IR
// WITH_STDLIB
// WITH_COROUTINES
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) }
}