[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:
Generated
+5
@@ -6853,6 +6853,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
@@ -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()
|
||||
+5
@@ -6853,6 +6853,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
+5
@@ -6853,6 +6853,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
+5
@@ -6853,6 +6853,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -5658,6 +5658,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
Generated
+5
@@ -5658,6 +5658,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
Generated
+5
@@ -5658,6 +5658,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt42554.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt44221.kt")
|
||||
public void testKt44221() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/kt44221.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lastExpressionIsLoop.kt")
|
||||
public void testLastExpressionIsLoop() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/lastExpressionIsLoop.kt");
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@ private fun translateFunctionCall(
|
||||
source = resolvedCall.call.callElement
|
||||
}))
|
||||
context.currentBlock.statements += statement
|
||||
return context.createCoroutineResult(resolvedCall)
|
||||
callExpression = context.createCoroutineResult(resolvedCall)
|
||||
}
|
||||
else {
|
||||
callExpression = callInfo.constructSafeCallIfNeeded(callExpression)
|
||||
|
||||
Reference in New Issue
Block a user