From f0006f24058ce74f16212d6f23b4e76a32920f13 Mon Sep 17 00:00:00 2001 From: Ilmir Usmanov Date: Thu, 4 Jun 2020 19:22:43 +0200 Subject: [PATCH] Minor. Add regression test #KT-39374 Fixed --- .../ir/FirBlackBoxCodegenTestGenerated.java | 9 +++++ .../testData/codegen/box/contracts/kt39374.kt | 34 +++++++++++++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 14 ++++++++ .../LightAnalysisModeTestGenerated.java | 14 ++++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 9 +++++ .../IrJsCodegenBoxES6TestGenerated.java | 9 +++++ .../IrJsCodegenBoxTestGenerated.java | 9 +++++ .../semantics/JsCodegenBoxTestGenerated.java | 9 +++++ 8 files changed, 107 insertions(+) create mode 100644 compiler/testData/codegen/box/contracts/kt39374.kt diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 83ba5a13209..a286dcc17e9 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -5078,6 +5078,10 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT KotlinTestUtils.runTestWithCustomIgnoreDirective(this::doTest, TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTestWithCustomIgnoreDirective(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath, "// IGNORE_BACKEND_FIR: "); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @@ -5112,6 +5116,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/compiler/testData/codegen/box/contracts/kt39374.kt b/compiler/testData/codegen/box/contracts/kt39374.kt new file mode 100644 index 00000000000..708010d3e92 --- /dev/null +++ b/compiler/testData/codegen/box/contracts/kt39374.kt @@ -0,0 +1,34 @@ +// IGNORE_BACKEND: NATIVE +// WITH_RUNTIME +// KJS_WITH_FULL_RUNTIME +// WITH_COROUTINES +// COMMON_COROUTINES_TEST + +import kotlin.contracts.* +import COROUTINES_PACKAGE.* +import helpers.* + +@ExperimentalContracts +public fun runBlocking(block: suspend () -> T): T { + contract { + callsInPlace(block, InvocationKind.EXACTLY_ONCE) + } + var res: T? = null + suspend { + res = block() + }.startCoroutine(EmptyContinuation) + return res!! +} + +sealed class S { + class Z : S() { + fun f(): String = "OK" + } +} + +val z: S = S.Z() + +@ExperimentalContracts +fun box(): String = when (val w = z) { + is S.Z -> runBlocking { w.f() } +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 9683b1d76b6..0eb022aa9ca 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -5108,6 +5108,10 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } @@ -5142,6 +5146,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 153717bac12..e32523d02c6 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -5108,6 +5108,10 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); } @@ -5142,6 +5146,16 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_2() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines.experimental"); + } + + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 22e70769cf5..cf5890717dc 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -5078,6 +5078,10 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JVM_IR, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); } @@ -5112,6 +5116,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 57c6e86e6f0..586191fbd50 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -4108,6 +4108,10 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR_ES6, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR_ES6, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); } @@ -4142,6 +4146,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index f1a242636c2..1670e47bcb6 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -4118,6 +4118,10 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS_IR, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); } @@ -4152,6 +4156,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index fb5e8481703..afaad93fc52 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -4118,6 +4118,10 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); } + private void runTestWithPackageReplacement(String testDataFilePath, String packageName) throws Exception { + KotlinTestUtils.runTest0(filePath -> doTestWithCoroutinesPackageReplacement(filePath, packageName), TargetBackend.JS, testDataFilePath); + } + public void testAllFilesPresentInContracts() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/contracts"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); } @@ -4152,6 +4156,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/contracts/functionParameter.kt"); } + @TestMetadata("kt39374.kt") + public void testKt39374_1_3() throws Exception { + runTestWithPackageReplacement("compiler/testData/codegen/box/contracts/kt39374.kt", "kotlin.coroutines"); + } + @TestMetadata("lambdaParameter.kt") public void testLambdaParameter() throws Exception { runTest("compiler/testData/codegen/box/contracts/lambdaParameter.kt");