[FIR] Assume smartacsts on member properties from friend modules as stable

^KT-57893 Fixed
This commit is contained in:
Dmitriy Novozhilov
2023-04-11 16:17:55 +03:00
committed by Space Team
parent 0d1500f23f
commit f8ef478647
8 changed files with 85 additions and 1 deletions
@@ -29764,6 +29764,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
}
@Test
@TestMetadata("smartcastInFriendModule.kt")
public void testSmartcastInFriendModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastInFriendModule.kt");
}
@Test
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
@@ -29764,6 +29764,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
}
@Test
@TestMetadata("smartcastInFriendModule.kt")
public void testSmartcastInFriendModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastInFriendModule.kt");
}
@Test
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
@@ -29764,6 +29764,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
}
@Test
@TestMetadata("smartcastInFriendModule.kt")
public void testSmartcastInFriendModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastInFriendModule.kt");
}
@Test
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
@@ -29860,6 +29860,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
}
@Test
@TestMetadata("smartcastInFriendModule.kt")
public void testSmartcastInFriendModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastInFriendModule.kt");
}
@Test
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {
@@ -176,7 +176,9 @@ class VariableStorageImpl(private val session: FirSession) : VariableStorage() {
val propertyModuleData = property.originalOrSelf().moduleData
val currentModuleData = session.moduleData
when (propertyModuleData) {
currentModuleData, in currentModuleData.dependsOnDependencies -> PropertyStability.STABLE_VALUE
currentModuleData,
in currentModuleData.friendDependencies,
in currentModuleData.dependsOnDependencies -> PropertyStability.STABLE_VALUE
else -> PropertyStability.ALIEN_PUBLIC_PROPERTY
}
}
@@ -0,0 +1,26 @@
// ISSUE: KT-57893
// MODULE: main
internal class A {
val x: String? = null
}
class B {
internal val x: String? = null
}
class C {
val x: String? = null
}
// MODULE: test()(main)
internal fun test(a: A, b: B, c: C) {
if (a.x != null) {
a.x.length
}
if (b.x != null) {
b.x.length
}
if (c.x != null) {
c.x.length
}
}
@@ -0,0 +1,26 @@
// ISSUE: KT-57893
// MODULE: main
internal class A {
val x: String? = null
}
class B {
internal val x: String? = null
}
class C {
val x: String? = null
}
// MODULE: test()(main)
internal fun test(a: A, b: B, c: C) {
if (a.x != null) {
<!DEBUG_INFO_SMARTCAST!>a.x<!>.length
}
if (b.x != null) {
<!DEBUG_INFO_SMARTCAST!>b.x<!>.length
}
if (c.x != null) {
<!SMARTCAST_IMPOSSIBLE!>c.x<!>.length
}
}
@@ -30626,6 +30626,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartCastOnWhen.kt");
}
@Test
@TestMetadata("smartcastInFriendModule.kt")
public void testSmartcastInFriendModule() throws Exception {
runTest("compiler/testData/diagnostics/tests/smartCasts/smartcastInFriendModule.kt");
}
@Test
@TestMetadata("smartcastOnSameFieldOfDifferentInstances.kt")
public void testSmartcastOnSameFieldOfDifferentInstances() throws Exception {