diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.fir.kt new file mode 100644 index 00000000000..1cbb749a12e --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.fir.kt @@ -0,0 +1,11 @@ +// TESTCASE NUMBER: 1 + +val y0 = when (2) { + else -> if (true) {""} +} + +val w:Any = TODO() + +val y1 = when (2) { + else -> if (true) {""} // false ok with coercion to Unit +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt new file mode 100644 index 00000000000..8c342ea4428 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt @@ -0,0 +1,20 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: coercion-to-unit + * NUMBER: 1 + * DESCRIPTION: Coercion to Unit error diagnostics absence + * ISSUES: KT-38490 + */ + +// TESTCASE NUMBER: 1 + +val y0 = when (2) { + else -> if (true) {""} +} + +val w:Any = TODO() + +val y1 = when (2) { + else -> if (true) {""} // false ok with coercion to Unit +} \ No newline at end of file diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.txt b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.txt new file mode 100644 index 00000000000..aad34e81ff6 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.txt @@ -0,0 +1,5 @@ +package + +public val w: kotlin.Any +public val y0: kotlin.Unit +public val y1: kotlin.Unit diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java index 124a724ae07..b4c297196ed 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/DiagnosticsTestSpecGenerated.java @@ -5055,6 +5055,37 @@ public class DiagnosticsTestSpecGenerated extends AbstractDiagnosticsTestSpec { } } + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Coercion_to_unit extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCoercion_to_unit() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Neg extends AbstractDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt"); + } + + public void testAllFilesPresentInNeg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + } + } + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/FirDiagnosticsTestSpecGenerated.java b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/FirDiagnosticsTestSpecGenerated.java index 93d8604e8d6..89711c0af14 100644 --- a/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/FirDiagnosticsTestSpecGenerated.java +++ b/compiler/tests-spec/tests/org/jetbrains/kotlin/spec/checkers/FirDiagnosticsTestSpecGenerated.java @@ -5055,6 +5055,37 @@ public class FirDiagnosticsTestSpecGenerated extends AbstractFirDiagnosticsTestS } } + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Coercion_to_unit extends AbstractFirDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCoercion_to_unit() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Neg extends AbstractFirDiagnosticsTestSpec { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + @TestMetadata("1.kt") + public void test1() throws Exception { + runTest("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg/1.kt"); + } + + public void testAllFilesPresentInNeg() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/tests-spec/testData/diagnostics/notLinked/coercion-to-unit/neg"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + } + } + @TestMetadata("compiler/tests-spec/testData/diagnostics/notLinked/contracts") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)