KT-53551 KT-52213 KT-58476 Fix handling of suspend functional types with context receivers
This commit is contained in:
committed by
Space Team
parent
c2ee9bb1a4
commit
88453a05f1
@@ -0,0 +1,20 @@
|
||||
// !LANGUAGE: +ContextReceivers
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
|
||||
class InContext
|
||||
class MyReciever {
|
||||
public suspend fun MyOutput.innerFun(): Int = 123
|
||||
}
|
||||
class MyOutput
|
||||
|
||||
// 2 - Declare the caller that calls the suspended function in a context
|
||||
public fun caller(block: suspend context(InContext) MyReciever.() -> Int): MyOutput = MyOutput()
|
||||
|
||||
fun box(): String {
|
||||
val out1 = caller { MyOutput().innerFun() }
|
||||
val out2 = with (InContext()) { caller { MyOutput().innerFun() } }
|
||||
val out3 = caller { with (InContext()) { MyOutput().innerFun() } }
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user