[FIR] Don't remove subsumed members from intersection overrides's overriddens

This fixes a bunch of missing overridden symbols in IR.
This is also required for fixing KT-59921 in the following commit
where we need to keep all overridden symbols of intersection overrides
so that we can enhance them properly.

#KT-57300 Fixed
#KT-57299 Fixed
#KT-59921
#KT-57300
#KT-62788
#KT-64271
#KT-64382
This commit is contained in:
Kirill Rakhman
2024-01-17 09:59:17 +01:00
committed by Space Team
parent d80dee6e1c
commit 3b841dcb98
58 changed files with 899 additions and 530 deletions
@@ -6,15 +6,15 @@ B:
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
C:
[Source]: public open override fun getFoo(): R|kotlin/String| from Java enhancement scope for /C [id: 0]
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /B [id: 0]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
[IntersectionOverride]: public open override fun getFoo(): R|kotlin/String| from Java enhancement scope for /C [id: 0]
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /B [id: 1]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
D:
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /D [id: 0]
[Source]: public open override fun getFoo(): R|kotlin/String| from Java enhancement scope for /C [id: 0]
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /B [id: 0]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 1]
[IntersectionOverride]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /D [id: 0]
[IntersectionOverride]: public open override fun getFoo(): R|kotlin/String| from Java enhancement scope for /C [id: 0]
[Source]: public open override fun getFoo(): R|kotlin/String| from Use site scope of /B [id: 1]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
[Enhancement]: public abstract fun getFoo(): R|kotlin/String!| from Java enhancement scope for /A [id: 2]
@@ -1,38 +1,38 @@
C:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
Explicit:
[Source]: public abstract override fun foo(): R|kotlin/Int| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 4]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 4]
Implicit:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[IntersectionOverride]: public abstract override val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 4]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 4]
@@ -1,38 +1,38 @@
C:
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 0]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 1]
Explicit:
[Source]: public abstract override fun foo(): R|kotlin/Int| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 4]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /Explicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 4]
Implicit:
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[IntersectionOverride]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override fun foo(): R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract fun foo(): R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 3]
[IntersectionOverride]: public abstract override val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract fun foo(): R|kotlin/Int| from Use site scope of /D [id: 4]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /Implicit [id: 0]
[IntersectionOverride]: public abstract val x: R|kotlin/Any| from Use site scope of /C [id: 1]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 1]
[Source]: public abstract override val x: R|kotlin/Any| from Use site scope of /B [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /A [id: 2]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 3]
[Source]: public abstract val x: R|kotlin/Any| from Use site scope of /D [id: 4]
@@ -1,11 +1,11 @@
D:
[SubstitutionOverride(DeclarationSite)]: public abstract override fun foo(): R|E4| from Use site scope of /D [id: 0]
[SubstitutionOverride(DeclarationSite)]: public abstract override fun foo(): R|E4| from Substitution scope for [Use site scope of /B] for type D<E4> [id: 0]
[Source]: public abstract override fun foo(): R|E2| from Use site scope of /B [id: 1]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E2| from Substitution scope for [Use site scope of /A] for type B<E2> [id: 2]
[Source]: public abstract fun foo(): R|E1| from Use site scope of /A [id: 3]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E4| from Substitution scope for [Use site scope of /C] for type D<E4> [id: 4]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E3| from Use site scope of /C [id: 5]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E3| from Substitution scope for [Use site scope of /A] for type C<E3> [id: 5]
[Source]: public abstract fun foo(): R|E1| from Use site scope of /A [id: 3]
[IntersectionOverride]: public abstract override fun foo(): R|E4| from Use site scope of /D [id: 0]
[SubstitutionOverride(DeclarationSite)]: public abstract override fun foo(): R|E4| from Substitution scope for [Use site scope of /B] for type D<E4> [id: 1]
[Source]: public abstract override fun foo(): R|E2| from Use site scope of /B [id: 2]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E2| from Substitution scope for [Use site scope of /A] for type B<E2> [id: 3]
[Source]: public abstract fun foo(): R|E1| from Use site scope of /A [id: 4]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E4| from Substitution scope for [Use site scope of /C] for type D<E4> [id: 5]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E3| from Use site scope of /C [id: 6]
[SubstitutionOverride(DeclarationSite)]: public abstract fun foo(): R|E3| from Substitution scope for [Use site scope of /A] for type C<E3> [id: 6]
[Source]: public abstract fun foo(): R|E1| from Use site scope of /A [id: 4]
@@ -345,6 +345,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
}
@Test
@TestMetadata("duplicateDefaultValuesSubsumedIntersection.kt")
public void testDuplicateDefaultValuesSubsumedIntersection() throws Exception {
runTest("compiler/testData/diagnostics/tests/duplicateDefaultValuesSubsumedIntersection.kt");
}
@Test
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
public void testDuplicateDirrectOverriddenCallables() throws Exception {
@@ -26462,6 +26468,36 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/override/InternalPotentialOverride.kt");
}
@Test
@TestMetadata("intersectionOfAbstractAndOpen.kt")
public void testIntersectionOfAbstractAndOpen() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOfAbstractAndOpen.kt");
}
@Test
@TestMetadata("intersectionOfSubstitutedProperties.kt")
public void testIntersectionOfSubstitutedProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOfSubstitutedProperties.kt");
}
@Test
@TestMetadata("intersectionOverrideWithSubsumedDifferentType.kt")
public void testIntersectionOverrideWithSubsumedDifferentType() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOverrideWithSubsumedDifferentType.kt");
}
@Test
@TestMetadata("intersectionOverridesIntersection.kt")
public void testIntersectionOverridesIntersection() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOverridesIntersection.kt");
}
@Test
@TestMetadata("intersectionWithSubsumedWithSubstitution.kt")
public void testIntersectionWithSubsumedWithSubstitution() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionWithSubsumedWithSubstitution.kt");
}
@Test
@TestMetadata("InvisiblePotentialOverride.kt")
public void testInvisiblePotentialOverride() throws Exception {
@@ -26729,6 +26765,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/override/clashesOnInheritance/genericWithUpperBound.kt");
}
@Test
@TestMetadata("intersectionReturnTypeMismatchSubsumed.kt")
public void testIntersectionReturnTypeMismatchSubsumed() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/clashesOnInheritance/intersectionReturnTypeMismatchSubsumed.kt");
}
@Test
@TestMetadata("kt13355.kt")
public void testKt13355() throws Exception {
@@ -345,6 +345,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/Dollar.kt");
}
@Test
@TestMetadata("duplicateDefaultValuesSubsumedIntersection.kt")
public void testDuplicateDefaultValuesSubsumedIntersection() throws Exception {
runTest("compiler/testData/diagnostics/tests/duplicateDefaultValuesSubsumedIntersection.kt");
}
@Test
@TestMetadata("duplicateDirrectOverriddenCallables.kt")
public void testDuplicateDirrectOverriddenCallables() throws Exception {
@@ -26468,6 +26474,36 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/override/InternalPotentialOverride.kt");
}
@Test
@TestMetadata("intersectionOfAbstractAndOpen.kt")
public void testIntersectionOfAbstractAndOpen() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOfAbstractAndOpen.kt");
}
@Test
@TestMetadata("intersectionOfSubstitutedProperties.kt")
public void testIntersectionOfSubstitutedProperties() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOfSubstitutedProperties.kt");
}
@Test
@TestMetadata("intersectionOverrideWithSubsumedDifferentType.kt")
public void testIntersectionOverrideWithSubsumedDifferentType() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOverrideWithSubsumedDifferentType.kt");
}
@Test
@TestMetadata("intersectionOverridesIntersection.kt")
public void testIntersectionOverridesIntersection() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionOverridesIntersection.kt");
}
@Test
@TestMetadata("intersectionWithSubsumedWithSubstitution.kt")
public void testIntersectionWithSubsumedWithSubstitution() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/intersectionWithSubsumedWithSubstitution.kt");
}
@Test
@TestMetadata("InvisiblePotentialOverride.kt")
public void testInvisiblePotentialOverride() throws Exception {
@@ -26735,6 +26771,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/override/clashesOnInheritance/genericWithUpperBound.kt");
}
@Test
@TestMetadata("intersectionReturnTypeMismatchSubsumed.kt")
public void testIntersectionReturnTypeMismatchSubsumed() throws Exception {
runTest("compiler/testData/diagnostics/tests/override/clashesOnInheritance/intersectionReturnTypeMismatchSubsumed.kt");
}
@Test
@TestMetadata("kt13355.kt")
public void testKt13355() throws Exception {