[K/N] Fix default arguments in suspend functions

AddContinuationToFunctionsLowering was rewritten in way the order
of this lowering and defaults lowering doesn't matter.

^KT-58214
This commit is contained in:
Pavel Kunyavskiy
2023-04-28 16:08:06 +02:00
committed by Space Team
parent fa1b22cf31
commit af318fdfb0
17 changed files with 117 additions and 94 deletions
@@ -14,6 +14,14 @@ class Controller1 {
x.resume(block())
COROUTINE_SUSPENDED
}
suspend fun getDef() = "DEF2"
suspend fun suspendHere2(block : suspend () -> String = { getDef() }): String {
val result = block()
return suspendCoroutineUninterceptedOrReturn { x ->
x.resume(result)
COROUTINE_SUSPENDED
}
}
}
fun builder1(c: suspend Controller1.() -> Unit) {
@@ -34,6 +42,10 @@ fun box(): String {
result = "FAIL"
return@builder1
}
if (suspendHere2() != "DEF2") {
result = "FAIL"
return@builder1
}
result = suspendHere { "OK" }
}
if (result != "OK") return result
@@ -44,6 +56,10 @@ fun box(): String {
result = "FAIL"
return@builder2
}
if (suspendHere2() != "DEF2") {
result = "FAIL"
return@builder2
}
result = suspendHere { "OK" }
}
@@ -62,6 +78,14 @@ class Controller2 {
x.resume(block())
COROUTINE_SUSPENDED
}
suspend fun getDef() = "DEF2"
suspend fun suspendHere2(block : suspend () -> String = { getDef() }): String {
val result = block()
return suspendCoroutineUninterceptedOrReturn { x ->
x.resume(result)
COROUTINE_SUSPENDED
}
}
}
fun builder2(c: suspend Controller2.() -> Unit) {