[K/JS] Fix problem with dynamic return type inside coroutine
This commit is contained in:
@@ -796,6 +796,24 @@ public class BoxJsTestGenerated extends AbstractBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/coroutines/debugStatement.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturn.kt")
|
||||
public void testDynamicSuspendReturn() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithArrayAccess.kt")
|
||||
public void testDynamicSuspendReturnWithArrayAccess() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithArrayAccess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithOperator.kt")
|
||||
public void testDynamicSuspendReturnWithOperator() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt54382.kt")
|
||||
public void testKt54382() throws Exception {
|
||||
|
||||
+18
@@ -860,6 +860,24 @@ public class FirJsBoxTestGenerated extends AbstractFirJsBoxTest {
|
||||
runTest("js/js.translator/testData/box/coroutines/debugStatement.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturn.kt")
|
||||
public void testDynamicSuspendReturn() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithArrayAccess.kt")
|
||||
public void testDynamicSuspendReturnWithArrayAccess() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithArrayAccess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithOperator.kt")
|
||||
public void testDynamicSuspendReturnWithOperator() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt54382.kt")
|
||||
public void testKt54382() throws Exception {
|
||||
|
||||
+18
@@ -860,6 +860,24 @@ public class IrBoxJsTestGenerated extends AbstractIrBoxJsTest {
|
||||
runTest("js/js.translator/testData/box/coroutines/debugStatement.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturn.kt")
|
||||
public void testDynamicSuspendReturn() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturn.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithArrayAccess.kt")
|
||||
public void testDynamicSuspendReturnWithArrayAccess() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithArrayAccess.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("dynamicSuspendReturnWithOperator.kt")
|
||||
public void testDynamicSuspendReturnWithOperator() throws Exception {
|
||||
runTest("js/js.translator/testData/box/coroutines/dynamicSuspendReturnWithOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt54382.kt")
|
||||
public void testKt54382() throws Exception {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// WITH_STDLIB
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun foo(): dynamic {
|
||||
return js("{ test: 'OK' }")
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object : Continuation<Unit> {
|
||||
override val context = EmptyCoroutineContext
|
||||
override fun resumeWith(result: Result<Unit>) {}
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
|
||||
builder {
|
||||
result += foo().test
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// WITH_STDLIB
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun foo(): dynamic {
|
||||
return js("[1, 2, 3]")
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object : Continuation<Unit> {
|
||||
override val context = EmptyCoroutineContext
|
||||
override fun resumeWith(result: Result<Unit>) {}
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: dynamic = 0
|
||||
val count = 0;
|
||||
|
||||
builder {
|
||||
result += foo()[count + 0] + foo()[count + 1] * foo()[count + 2]
|
||||
}
|
||||
|
||||
return if (result == 7) "OK" else "fail: the wrong answer. Expect to have 7 but got $result"
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// IGNORE_BACKEND: JS
|
||||
// WITH_STDLIB
|
||||
// EXPECTED_REACHABLE_NODES: 1292
|
||||
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
suspend fun foo(): dynamic {
|
||||
return 2
|
||||
}
|
||||
|
||||
fun builder(c: suspend () -> Unit) {
|
||||
c.startCoroutine(object : Continuation<Unit> {
|
||||
override val context = EmptyCoroutineContext
|
||||
override fun resumeWith(result: Result<Unit>) {}
|
||||
})
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
var result: dynamic = 1
|
||||
|
||||
builder {
|
||||
result += foo() + 2 + result + foo()
|
||||
}
|
||||
|
||||
return if (result == 8) "OK" else "fail: the wrong answer. Expect to have 8 but got $result"
|
||||
}
|
||||
Reference in New Issue
Block a user