From 852475337b3aacd3d6fab601fe55b726556e217e Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 1 Dec 2021 11:22:49 +0300 Subject: [PATCH] FIR: use only most specific members when building intersection In this commit we drop less concrete members in intersection. See for example change in test data: before the commit, we intersected all three A.foo, B.foo and C.foo in diamond hierarchy. After the commit we drop A.foo and intersect B.foo and C.foo only. --- .../fir/scopes/impl/FirTypeIntersectionScope.kt | 2 +- .../tests/override/FakeOverrideModality3.fir.kt | 16 ---------------- .../tests/override/FakeOverrideModality3.kt | 1 + 3 files changed, 2 insertions(+), 17 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/override/FakeOverrideModality3.fir.kt diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt index 0cef5fc4be8..7353829442e 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScope.kt @@ -112,7 +112,7 @@ class FirTypeIntersectionScope private constructor( mostSpecific, FirIntersectionOverrideStorage.ContextForIntersectionOverrideConstruction( this, - extractedOverrides, + baseMembersForIntersection, scopeForMostSpecific ) ) diff --git a/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.fir.kt b/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.fir.kt deleted file mode 100644 index 9aca1afc65f..00000000000 --- a/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.fir.kt +++ /dev/null @@ -1,16 +0,0 @@ -interface A { - fun foo() {} -} - -interface B : A { - abstract override fun foo() -} - -interface C : A { - abstract override fun foo() -} - -interface D : A - -// Fake override Z#foo should be abstract -class Z : B, C, D diff --git a/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.kt b/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.kt index 485981df58d..e199f95f23d 100644 --- a/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.kt +++ b/compiler/testData/diagnostics/tests/override/FakeOverrideModality3.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL interface A { fun foo() {} }