[K/N] Fix default argument lambda in suspend function code generation
This commit is contained in:
committed by
Space Team
parent
484d3ad273
commit
e655e0a809
+6
@@ -10249,6 +10249,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
|
||||
+6
@@ -10249,6 +10249,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
// WITH_STDLIB
|
||||
// WITH_COROUTINES
|
||||
|
||||
// lowered IR can be dependent on file order here, so we will test both
|
||||
|
||||
// FILE: A.kt
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
class Controller1 {
|
||||
suspend fun suspendHere(block : () -> String = { "DEF" }): String = suspendCoroutineUninterceptedOrReturn { x ->
|
||||
x.resume(block())
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
fun builder1(c: suspend Controller1.() -> Unit) {
|
||||
c.startCoroutine(Controller1(), EmptyContinuation)
|
||||
}
|
||||
|
||||
// FILE: B.kt
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "FAIL 1"
|
||||
|
||||
builder1 {
|
||||
if (suspendHere() != "DEF") {
|
||||
result = "FAIL"
|
||||
return@builder1
|
||||
}
|
||||
result = suspendHere { "OK" }
|
||||
}
|
||||
if (result != "OK") return result
|
||||
result = "FAIL 2"
|
||||
|
||||
builder2 {
|
||||
if (suspendHere() != "DEF") {
|
||||
result = "FAIL"
|
||||
return@builder2
|
||||
}
|
||||
result = suspendHere { "OK" }
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// FILE: C.kt
|
||||
|
||||
import helpers.*
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
|
||||
|
||||
class Controller2 {
|
||||
suspend fun suspendHere(block : () -> String = { "DEF" }): String = suspendCoroutineUninterceptedOrReturn { x ->
|
||||
x.resume(block())
|
||||
COROUTINE_SUSPENDED
|
||||
}
|
||||
}
|
||||
|
||||
fun builder2(c: suspend Controller2.() -> Unit) {
|
||||
c.startCoroutine(Controller2(), EmptyContinuation)
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -10009,6 +10009,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
|
||||
+6
@@ -10249,6 +10249,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
|
||||
+6
@@ -10249,6 +10249,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
|
||||
+5
@@ -7877,6 +7877,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParametersInSuspendWithJvmOverloads.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("defaultParamterLambdaInSuspend.kt")
|
||||
public void testDefaultParamterLambdaInSuspend() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/defaultParamterLambdaInSuspend.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedSuspendMember.kt")
|
||||
public void testDelegatedSuspendMember() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/coroutines/delegatedSuspendMember.kt");
|
||||
|
||||
Reference in New Issue
Block a user