From 39ebc8cfa5a95b7d7caa79d981dffd2c0ca6a996 Mon Sep 17 00:00:00 2001 From: pyos Date: Thu, 20 Feb 2020 11:38:58 +0100 Subject: [PATCH] Add a suspend test that fails on JVM_IR --- ...ubleRegenerationWithNonSuspendingLambda.kt | 50 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 10 ++++ ...otlinAgainstInlineKotlinTestGenerated.java | 10 ++++ .../IrBlackBoxInlineCodegenTestGenerated.java | 5 ++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 ++ .../IrInlineSuspendTestsGenerated.java | 5 ++ .../InlineSuspendTestsGenerated.java | 5 ++ 7 files changed, 90 insertions(+) create mode 100644 compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt diff --git a/compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt b/compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt new file mode 100644 index 00000000000..a904f0cec31 --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt @@ -0,0 +1,50 @@ +// FILE: test.kt +// COMMON_COROUTINES_TEST +// WITH_RUNTIME +// WITH_COROUTINES +// IGNORE_BACKEND: JVM_IR +// IGNORE_BACKEND_MULTI_MODULE: JVM_IR + +interface Flow { + abstract suspend fun collect(collector: FlowCollector) +} + +interface FlowCollector { + suspend fun emit(value: T) +} + +inline fun flow(crossinline body: suspend FlowCollector.() -> Unit): Flow = + object : Flow { + override suspend fun collect(collector: FlowCollector) = collector.body() + } + +suspend inline fun Flow.collect(crossinline body: suspend (T) -> Unit) = + collect(object : FlowCollector { + override suspend fun emit(value: T) = body(value) + }) + +inline fun Flow.filter(crossinline predicate: suspend (T) -> Boolean): Flow = + flow { + this@filter.collect { if (predicate(it)) emit(it) } + } + +inline fun Flow<*>.filterIsInstance(): Flow = + filter { it is R } as Flow + +// FILE: box.kt +// COMMON_COROUTINES_TEST + +import COROUTINES_PACKAGE.* +import helpers.* + +fun builder(c: suspend () -> Unit) { + c.startCoroutine(EmptyContinuation) +} + +fun box(): String { + var result = "fail" + builder { + flow { emit("OK") }.filterIsInstance().collect { result = it } + } + return result +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 62e90f40112..3e15a340734 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -3653,6 +3653,16 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("enclodingMethod.kt") public void testEnclodingMethod_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 016402beb3a..5f816892147 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3653,6 +3653,16 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("enclodingMethod.kt") public void testEnclodingMethod_1_2() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines.experimental"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 71a15fdabdf..959cefc93a6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -3643,6 +3643,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("enclodingMethod.kt") public void testEnclodingMethod_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 98528ce5ba8..74e1d5f456d 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -3643,6 +3643,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("enclodingMethod.kt") public void testEnclodingMethod_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/enclodingMethod.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrInlineSuspendTestsGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrInlineSuspendTestsGenerated.java index e897b1da130..65ae2605c03 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrInlineSuspendTestsGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrInlineSuspendTestsGenerated.java @@ -43,6 +43,11 @@ public class IrInlineSuspendTestsGenerated extends AbstractIrInlineSuspendTests runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt") public void testInlineOrdinaryOfCrossinlineSuspend_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineSuspendTestsGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineSuspendTestsGenerated.java index b3f04d30090..b160d92e5a3 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineSuspendTestsGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineSuspendTestsGenerated.java @@ -43,6 +43,11 @@ public class InlineSuspendTestsGenerated extends AbstractInlineSuspendTests { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/crossinlineSuspendLambdaInsideCrossinlineSuspendLambda.kt", "kotlin.coroutines"); } + @TestMetadata("doubleRegenerationWithNonSuspendingLambda.kt") + public void testDoubleRegenerationWithNonSuspendingLambda_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/doubleRegenerationWithNonSuspendingLambda.kt", "kotlin.coroutines"); + } + @TestMetadata("inlineOrdinaryOfCrossinlineSuspend.kt") public void testInlineOrdinaryOfCrossinlineSuspend_1_3() throws Exception { runTestWithPackageReplacement("compiler/testData/codegen/boxInline/suspend/inlineOrdinaryOfCrossinlineSuspend.kt", "kotlin.coroutines");