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 1126f2cca22..c6a6a5ba302 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 @@ -36891,6 +36891,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/smartCasts/variables/property.kt"); } + @Test + @TestMetadata("propertyFromDependsOnModule.kt") + public void testPropertyFromDependsOnModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt"); + } + @Test @TestMetadata("propertyNotNeeded.kt") public void testPropertyNotNeeded() 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 962e2b5ecf5..6eccd438407 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 @@ -36891,6 +36891,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/smartCasts/variables/property.kt"); } + @Test + @TestMetadata("propertyFromDependsOnModule.kt") + public void testPropertyFromDependsOnModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt"); + } + @Test @TestMetadata("propertyNotNeeded.kt") public void testPropertyNotNeeded() 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 f8d6ec1ab0a..16a7705b270 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 @@ -34535,6 +34535,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/smartCasts/variables/property.kt"); } + @Test + @TestMetadata("propertyFromDependsOnModule.kt") + public void testPropertyFromDependsOnModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt"); + } + @Test @TestMetadata("propertyNotNeeded.kt") public void testPropertyNotNeeded() 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 1dd3290777b..51d175c703a 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 @@ -34661,6 +34661,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/smartCasts/variables/property.kt"); } + @Test + @TestMetadata("propertyFromDependsOnModule.kt") + public void testPropertyFromDependsOnModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt"); + } + @Test @TestMetadata("propertyNotNeeded.kt") public void testPropertyNotNeeded() throws Exception { diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.fir.kt new file mode 100644 index 00000000000..66e1747ed23 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.fir.kt @@ -0,0 +1,33 @@ +// SKIP_TXT + +// MODULE: transitive +// FILE: Transitive.kt +class Transitive { + val finalProperty: Any = ""; +} + + +// MODULE: direct()()(transitive) +// FILE: Direct.kt +class Direct { + val finalProperty: Any = ""; +} + +// MODULE: app()()(direct) +fun isCast(d: Direct, t: Transitive) { + if (d.finalProperty is String) { + d.finalProperty.length + } + + if (t.finalProperty is String) { + t.finalProperty.length + } +} + +fun asCast(d: Direct, t: Transitive) { + d.finalProperty as String + d.finalProperty.length + + t.finalProperty as String + t.finalProperty.length +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt b/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt new file mode 100644 index 00000000000..3f6a6ded31d --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt @@ -0,0 +1,33 @@ +// SKIP_TXT + +// MODULE: transitive +// FILE: Transitive.kt +class Transitive { + val finalProperty: Any = ""; +} + + +// MODULE: direct()()(transitive) +// FILE: Direct.kt +class Direct { + val finalProperty: Any = ""; +} + +// MODULE: app()()(direct) +fun isCast(d: Direct, t: Transitive) { + if (d.finalProperty is String) { + d.finalProperty.length + } + + if (t.finalProperty is String) { + t.finalProperty.length + } +} + +fun asCast(d: Direct, t: Transitive) { + d.finalProperty as String + d.finalProperty.length + + t.finalProperty as String + t.finalProperty.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 7ec8a69b7b1..c4b13ce6bef 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 @@ -36891,6 +36891,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/smartCasts/variables/property.kt"); } + @Test + @TestMetadata("propertyFromDependsOnModule.kt") + public void testPropertyFromDependsOnModule() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/variables/propertyFromDependsOnModule.kt"); + } + @Test @TestMetadata("propertyNotNeeded.kt") public void testPropertyNotNeeded() throws Exception {