diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 002ed2df5c6..408aa2132d7 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -30181,9 +30181,15 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } @Test - @TestMetadata("smartCastOnAlienPropertyFromInnerClass.kt") - public void testSmartCastOnAlienPropertyFromInnerClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt"); + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClass.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt"); + } + + @Test + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClassForbidden.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClassForbidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt"); } @Test 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 361ac71ae5e..361ff86a71b 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 @@ -30181,9 +30181,15 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir } @Test - @TestMetadata("smartCastOnAlienPropertyFromInnerClass.kt") - public void testSmartCastOnAlienPropertyFromInnerClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt"); + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClass.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt"); + } + + @Test + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClassForbidden.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClassForbidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt"); } @Test 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 4248f350a59..874ee56185f 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 @@ -30277,9 +30277,15 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia } @Test - @TestMetadata("smartCastOnAlienPropertyFromInnerClass.kt") - public void testSmartCastOnAlienPropertyFromInnerClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt"); + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClass.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt"); + } + + @Test + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClassForbidden.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClassForbidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt"); } @Test diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.diag.txt b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.diag.txt similarity index 70% rename from compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.diag.txt rename to compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.diag.txt index 5020b6e1af0..ef0a171a36d 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.diag.txt +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.diag.txt @@ -1,10 +1,10 @@ // -- Module: -- // -- Module: -- -/B.kt:13:13: warning: smart cast to 'String' is deprecated, because 'x' is a property declared in base class from different module inherited in non-public API class +/B.kt:14:13: warning: smart cast to 'String' is deprecated, because 'x' is a property declared in base class from different module inherited in non-public API class x.length ^ -/B.kt:22:9: warning: smart cast to 'String' is deprecated, because 'i.x' is a property declared in base class from different module inherited in non-public API class +/B.kt:23:9: warning: smart cast to 'String' is deprecated, because 'i.x' is a property declared in base class from different module inherited in non-public API class i.x.length ^ diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.fir.kt b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.fir.kt similarity index 73% rename from compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.fir.kt rename to compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.fir.kt index d78f2d16c82..8f30438a1f4 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.fir.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.fir.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitSmartcastsOnPropertyFromAlienBaseClassInheritedInInvisibleClass // RENDER_DIAGNOSTICS_FULL_TEXT // MODULE: m1 // FILE: A.kt @@ -19,6 +20,6 @@ internal class Internal : Base("456") internal fun bar(i: Internal) { if (i.x is String) { - i.x.length + i.x.length } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt similarity index 84% rename from compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt rename to compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt index d8694c2e9ce..4a2c814cdc4 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitSmartcastsOnPropertyFromAlienBaseClassInheritedInInvisibleClass // RENDER_DIAGNOSTICS_FULL_TEXT // MODULE: m1 // FILE: A.kt diff --git a/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt new file mode 100644 index 00000000000..b79e0930ef6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt @@ -0,0 +1,25 @@ +// FIR_IDENTICAL +// !LANGUAGE: +ProhibitSmartcastsOnPropertyFromAlienBaseClassInheritedInInvisibleClass +// MODULE: m1 +// FILE: A.kt + +open class Base(val x: Any) + +// MODULE: m2(m1) +// FILE: B.kt + +private class Derived : Base("123") { + fun foo() { + if (x is String) { + x.length + } + } +} + +internal class Internal : Base("456") + +internal fun bar(i: Internal) { + if (i.x is String) { + i.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 ccd1cd0e892..02c40eda1a6 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 @@ -30277,9 +30277,15 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } @Test - @TestMetadata("smartCastOnAlienPropertyFromInnerClass.kt") - public void testSmartCastOnAlienPropertyFromInnerClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInnerClass.kt"); + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClass.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClass.kt"); + } + + @Test + @TestMetadata("smartCastOnAlienPropertyFromInvisibleClassForbidden.kt") + public void testSmartCastOnAlienPropertyFromInvisibleClassForbidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnAlienPropertyFromInvisibleClassForbidden.kt"); } @Test