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 92260dc60d0..7e0a8cc536b 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 @@ -20319,6 +20319,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/hashtableInheritance.kt"); } + @Test + @TestMetadata("inheritanceThroughEmptyClass.kt") + public void testInheritanceThroughEmptyClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt"); + } + @Test @TestMetadata("securityProvider.kt") public void testSecurityProvider() 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 4ed44994991..32022683bcd 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 @@ -20319,6 +20319,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/hashtableInheritance.kt"); } + @Test + @TestMetadata("inheritanceThroughEmptyClass.kt") + public void testInheritanceThroughEmptyClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt"); + } + @Test @TestMetadata("securityProvider.kt") public void testSecurityProvider() 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 2d4c4fa0f66..bdbf039ce28 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 @@ -20319,6 +20319,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/hashtableInheritance.kt"); } + @Test + @TestMetadata("inheritanceThroughEmptyClass.kt") + public void testInheritanceThroughEmptyClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt"); + } + @Test @TestMetadata("securityProvider.kt") public void testSecurityProvider() 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 9d2c987d5f5..a08cec491b6 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 @@ -20325,6 +20325,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/hashtableInheritance.kt"); } + @Test + @TestMetadata("inheritanceThroughEmptyClass.kt") + public void testInheritanceThroughEmptyClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt"); + } + @Test @TestMetadata("securityProvider.kt") public void testSecurityProvider() throws Exception { diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScopeContext.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScopeContext.kt index f02f26196aa..3e3f02c02b5 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScopeContext.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/FirTypeIntersectionScopeContext.kt @@ -10,7 +10,6 @@ import org.jetbrains.kotlin.descriptors.Visibilities import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.caches.* -import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration import org.jetbrains.kotlin.fir.declarations.FirVariable @@ -310,10 +309,12 @@ class FirTypeIntersectionScopeContext( symbol: D, scope: FirTypeScope, result: MutableCollection>, - visited: MutableSet, + // There's no guarantee that directOverridden(symbol) is strictly different + // It might be the same instance that when being requested with a different/new scope would return next level of overridden + visited: MutableSet>, processDirectOverridden: FirTypeScope.(D, (D, FirTypeScope) -> ProcessorAction) -> ProcessorAction, ) { - if (!visited.add(symbol)) return + if (!visited.add(scope to symbol)) return if (!symbol.fir.origin.fromSupertypes) { result.add(MemberWithBaseScope(symbol, scope)) return diff --git a/compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt b/compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt new file mode 100644 index 00000000000..78aaa4eb096 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt @@ -0,0 +1,84 @@ +// FIR_IDENTICAL +// FULL_JDK +// ISSUE: KT-57693 + +// FILE: AbstractCollectionDecorator.java +import java.util.Collection; +import java.util.Iterator; +import java.util.function.Predicate; + +public abstract class AbstractCollectionDecorator implements Collection { + + protected Collection decorated() { + return null; + } + + public boolean add(E object) { + return this.decorated().add(object); + } + + public boolean addAll(Collection coll) { + return this.decorated().addAll(coll); + } + + public void clear() { + this.decorated().clear(); + } + + public boolean contains(Object object) { + return this.decorated().contains(object); + } + + public boolean isEmpty() { + return this.decorated().isEmpty(); + } + + public Iterator iterator() { + return this.decorated().iterator(); + } + + public boolean remove(Object object) { + return this.decorated().remove(object); + } + + public int size() { + return this.decorated().size(); + } + + public Object[] toArray() { + return this.decorated().toArray(); + } + + public T[] toArray(T[] object) { + return this.decorated().toArray(object); + } + + public boolean containsAll(Collection coll) { + return this.decorated().containsAll(coll); + } + + public boolean removeIf(Predicate filter) { + return this.decorated().removeIf(filter); + } + + public boolean removeAll(Collection coll) { + return this.decorated().removeAll(coll); + } + + public boolean retainAll(Collection coll) { + return this.decorated().retainAll(coll); + } + + public String toString() { + return this.decorated().toString(); + } +} + +// FILE: AbstractSerializableListDecorator.java +public abstract class AbstractSerializableListDecorator extends AbstractCollectionDecorator { +} + +// FILE: main.kt +import java.util.* + +class UniqueArrayList : AbstractSerializableListDecorator(), MutableSet 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 1ce5e3dc603..3058aa73935 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 @@ -20325,6 +20325,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/hashtableInheritance.kt"); } + @Test + @TestMetadata("inheritanceThroughEmptyClass.kt") + public void testInheritanceThroughEmptyClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/j+k/specialBuiltIns/inheritanceThroughEmptyClass.kt"); + } + @Test @TestMetadata("securityProvider.kt") public void testSecurityProvider() throws Exception {