JS: initialize fields of coroutine state machine with undefined value so that they match local variable semantics. Fix KT-15366

This commit is contained in:
Alexey Andreev
2016-12-21 16:02:36 +03:00
parent 8ef284daf4
commit cef32b3327
7 changed files with 82 additions and 1 deletions
@@ -0,0 +1,30 @@
// MODULE: lib
// FILE: lib.kt
inline fun foo(x: String = "OK"): String {
return x + x
}
// MODULE: main(lib)
// FILE: main.kt
// WITH_RUNTIME
// WITH_COROUTINES
import kotlin.coroutines.*
var result = ""
fun builder(c: suspend () -> Unit) {
c.startCoroutine(object : Continuation<Unit> {
override fun resume(value: Unit) {
}
override fun resumeWithException(exception: Throwable) {
}
})
}
fun box(): String {
builder {
result = foo()
}
if (result != "OKOK") return "fail: $result"
return "OK"
}