From 7eedcf75f9a0651ae5b32de7cba32b47c4db1406 Mon Sep 17 00:00:00 2001 From: pyos Date: Mon, 17 May 2021 12:55:18 +0200 Subject: [PATCH] Add tests for default inline suspend lambdas Broken on JVM and JVM_IR --- ...FirBlackBoxInlineCodegenTestGenerated.java | 12 +++++++++ .../defaultParameter/defaultInlineLambda.kt | 24 +++++++++++++++++ .../defaultInlineReference.kt | 26 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 12 +++++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 +++++++++ .../IrBlackBoxInlineCodegenTestGenerated.java | 12 +++++++++ ...otlinAgainstInlineKotlinTestGenerated.java | 12 +++++++++ ...JvmIrAgainstOldBoxInlineTestGenerated.java | 12 +++++++++ ...JvmOldAgainstIrBoxInlineTestGenerated.java | 12 +++++++++ .../IrJsCodegenInlineES6TestGenerated.java | 10 +++++++ .../IrJsCodegenInlineTestGenerated.java | 10 +++++++ .../JsCodegenInlineTestGenerated.java | 10 +++++++ 12 files changed, 164 insertions(+) create mode 100644 compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt create mode 100644 compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java index aa6029f6301..4b18916e8c1 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxInlineCodegenTestGenerated.java @@ -4935,6 +4935,18 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt b/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt new file mode 100644 index 00000000000..30f2201c977 --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt @@ -0,0 +1,24 @@ +// SKIP_INLINE_CHECK_IN: bar$default +// WITH_RUNTIME +// WITH_COROUTINES +// IGNORE_BACKEND: JVM, JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR, JVM_MULTI_MODULE_OLD_AGAINST_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD +// FILE: 1.kt +package test + +inline fun bar(crossinline block: suspend (String) -> String = { it }): suspend () -> String = + { block("OK") } + +// FILE: 2.kt +import test.* +import helpers.* +import kotlin.coroutines.* + +fun box(): String { + var result = "fail" + suspend { + result = bar()() + }.startCoroutine(EmptyContinuation) + return result +} diff --git a/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt b/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt new file mode 100644 index 00000000000..76863b47f5e --- /dev/null +++ b/compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt @@ -0,0 +1,26 @@ +// SKIP_INLINE_CHECK_IN: bar$default +// WITH_RUNTIME +// WITH_COROUTINES +// IGNORE_BACKEND: JVM, JVM_IR +// IGNORE_BACKEND_FIR: JVM_IR +// IGNORE_BACKEND_MULTI_MODULE: JVM, JVM_IR, JVM_MULTI_MODULE_OLD_AGAINST_IR, JVM_MULTI_MODULE_IR_AGAINST_OLD +// FILE: 1.kt +package test + +suspend fun foo(x: String) = x + +inline fun bar(crossinline block: suspend (String) -> String = ::foo): suspend () -> String = + { block("OK") } + +// FILE: 2.kt +import test.* +import helpers.* +import kotlin.coroutines.* + +fun box(): String { + var result = "fail" + suspend { + result = bar()() + }.startCoroutine(EmptyContinuation) + return result +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java index c4adaaaea85..291d0aff4bf 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -4935,6 +4935,18 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 540123bbd70..16622ea23ab 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4935,6 +4935,18 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java index 479eaaee14d..09234c72aa1 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxInlineCodegenTestGenerated.java @@ -4935,6 +4935,18 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index 8b4154fb694..bde6f41cc1a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -4935,6 +4935,18 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java index c2e5c49b65c..e6e0817715d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -4935,6 +4935,18 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_IR_AGAINST_OLD, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java index db3c407f0fe..84e730a83a2 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -4935,6 +4935,18 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_MULTI_MODULE_OLD_AGAINST_IR, true); } + @Test + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @Test + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @Test @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index 3e2d4269b76..548ed25055e 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -3947,6 +3947,16 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultValueCrossinline.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 22f122998b9..b49c1853f7c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -3947,6 +3947,16 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultValueCrossinline.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 31fb9523087..5f99520a06c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -3947,6 +3947,16 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxInline/suspend/defaultParameter"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } + @TestMetadata("defaultInlineLambda.kt") + public void testDefaultInlineLambda() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineLambda.kt"); + } + + @TestMetadata("defaultInlineReference.kt") + public void testDefaultInlineReference() throws Exception { + runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultInlineReference.kt"); + } + @TestMetadata("defaultValueCrossinline.kt") public void testDefaultValueCrossinline() throws Exception { runTest("compiler/testData/codegen/boxInline/suspend/defaultParameter/defaultValueCrossinline.kt");