[JS Legacy] Fix returning Char from suspend functions (KT-44221)
Mark translated expression with a proper type, like we do with non-suspending calls, to coerce it later.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
// WITH_RUNTIME
|
||||
|
||||
import kotlin.coroutines.*
|
||||
|
||||
fun launch(block: suspend () -> String): String {
|
||||
var result = ""
|
||||
block.startCoroutine(Continuation(EmptyCoroutineContext) { result = it.getOrThrow() })
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
private class CharTest {
|
||||
private val test: Char = '!'
|
||||
|
||||
fun simpleTest() = launch {
|
||||
val ch = get()
|
||||
if (ch == '!') "OK" else "Fail"
|
||||
}
|
||||
|
||||
suspend fun get(): Char? = test
|
||||
}
|
||||
|
||||
|
||||
fun box(): String = CharTest().simpleTest()
|
||||
Reference in New Issue
Block a user