JVM_IR KT-47984 don't move inplace arguments with suspension points

This commit is contained in:
Dmitry Petrov
2021-08-07 12:27:33 +03:00
committed by TeamCityServer
parent 9acdcc7590
commit 9be941def2
11 changed files with 132 additions and 14 deletions
@@ -0,0 +1,25 @@
// IGNORE_BACKEND: WASM
// WITH_RUNTIME
import kotlin.coroutines.*
fun runs(f: suspend () -> String): String {
var result: String? = null
f.startCoroutine(
Continuation(EmptyCoroutineContext) {
result = it.getOrThrow()
}
)
return result ?: "Fail"
}
suspend fun suspendListOf(s: String) = listOf(s)
val strings: MutableCollection<String> = ArrayList()
fun box(): String {
return runs {
strings += suspendListOf("OK")
strings.iterator().next()
}
}