From dd85a81d45d312320a5e4cc40655ed6ad56de072 Mon Sep 17 00:00:00 2001 From: Nikolay Lunyak Date: Thu, 4 Jan 2024 13:25:02 +0200 Subject: [PATCH] [FIR] Add a minimized alternative for orOperatorWithConstant.kt It was decided to leave this code as is, because supporting it would probably require introducing Implication-statements, but this is not a good-enough use-case for such work. --- .../DiagnosticCompilerTestFE10TestdataTestGenerated.java | 6 ++++++ ...versedDiagnosticCompilerFE10TestDataTestGenerated.java | 6 ++++++ .../FirLightTreeOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../FirPsiOldFrontendDiagnosticsTestGenerated.java | 6 ++++++ .../tests/smartCasts/smartCastWithOrFalse.fir.kt | 8 ++++++++ .../diagnostics/tests/smartCasts/smartCastWithOrFalse.kt | 8 ++++++++ .../kotlin/test/runners/DiagnosticTestGenerated.java | 6 ++++++ 7 files changed, 46 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.fir.kt create mode 100644 compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 45b0d905994..6eda2d2ef3d 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -35020,6 +35020,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt"); } + @Test + @TestMetadata("smartCastWithOrFalse.kt") + public void testSmartCastWithOrFalse() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt"); + } + @Test @TestMetadata("smartcastInFriendModule.kt") public void testSmartcastInFriendModule() throws Exception { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index f5bec97b8d0..76da35ae223 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -35020,6 +35020,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt"); } + @Test + @TestMetadata("smartCastWithOrFalse.kt") + public void testSmartCastWithOrFalse() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt"); + } + @Test @TestMetadata("smartcastInFriendModule.kt") public void testSmartcastInFriendModule() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 9cdcbf84d57..22b89862189 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -32740,6 +32740,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt"); } + @Test + @TestMetadata("smartCastWithOrFalse.kt") + public void testSmartCastWithOrFalse() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt"); + } + @Test @TestMetadata("smartcastInFriendModule.kt") public void testSmartcastInFriendModule() throws Exception { diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index afe502dbf2f..a7e0019cc97 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -32860,6 +32860,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt"); } + @Test + @TestMetadata("smartCastWithOrFalse.kt") + public void testSmartCastWithOrFalse() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt"); + } + @Test @TestMetadata("smartcastInFriendModule.kt") public void testSmartcastInFriendModule() throws Exception { diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.fir.kt new file mode 100644 index 00000000000..c0b962b027f --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.fir.kt @@ -0,0 +1,8 @@ +fun main(x: Any?) { + if (x is String || false) { + x.length + } + else { + x.length + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt b/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt new file mode 100644 index 00000000000..fc13b42077c --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt @@ -0,0 +1,8 @@ +fun main(x: Any?) { + if (x is String || false) { + x.length + } + else { + x.length + } +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index c620a63f5f2..23134115525 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -35020,6 +35020,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt"); } + @Test + @TestMetadata("smartCastWithOrFalse.kt") + public void testSmartCastWithOrFalse() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastWithOrFalse.kt"); + } + @Test @TestMetadata("smartcastInFriendModule.kt") public void testSmartcastInFriendModule() throws Exception {