diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt index 7f64228a6d8..959293629bc 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt @@ -163,7 +163,7 @@ fun FirDeclarationCollector>.collectClassMembers(klass: FirReg collect(declaredFunction, FirRedeclarationPresenter.represent(declaredFunction), functionDeclarations) - unsubstitutedScope.collectLeafFunctionsByName(declaredFunction.name).forEach { anotherFunction -> + unsubstitutedScope.processFunctionsByName(declaredFunction.name) { anotherFunction -> if (anotherFunction != declaredFunction && anotherFunction.isCollectable() && anotherFunction.isVisibleInClass(klass)) { collect(anotherFunction, FirRedeclarationPresenter.represent(anotherFunction), functionDeclarations) } @@ -190,7 +190,7 @@ fun FirDeclarationCollector>.collectClassMembers(klass: FirReg collect(declaredProperty, FirRedeclarationPresenter.represent(declaredProperty), otherDeclarations) - unsubstitutedScope.collectLeafPropertiesByName(declaredProperty.name).forEach { anotherProperty -> + unsubstitutedScope.processPropertiesByName(declaredProperty.name) { anotherProperty -> if (anotherProperty != declaredProperty && anotherProperty.isCollectable() && anotherProperty.isVisibleInClass(klass)) { collect(anotherProperty, FirRedeclarationPresenter.represent(anotherProperty), otherDeclarations) } diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt index 0a5cc66626c..7f998f75054 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/scopes/impl/AbstractFirOverrideScope.kt @@ -31,7 +31,7 @@ abstract class AbstractFirOverrideScope( val baseDeclaration = (this as FirBasedSymbol<*>).fir as FirCallableDeclaration val override = overrideCandidates.firstOrNull { val overrideCandidate = (it as FirBasedSymbol<*>).fir as FirCallableDeclaration - baseDeclaration.modality != Modality.FINAL && overrideChecker.similarFunctionsOrBothProperties( + overrideChecker.similarFunctionsOrBothProperties( overrideCandidate, baseDeclaration ) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirContainingNamesAwareScope.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirContainingNamesAwareScope.kt index 58060511d98..1fbcf6fd25f 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirContainingNamesAwareScope.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/scopes/FirContainingNamesAwareScope.kt @@ -39,50 +39,6 @@ fun FirContainingNamesAwareScope.processAllClassifiers(processor: (FirClassifier } } -inline fun > collectLeafCallablesByName( - name: Name, - processCallablesByName: (Name, (T) -> Unit) -> Unit, - crossinline processDirectlyOverriddenCallables: (T, (T) -> ProcessorAction) -> Unit, -): List { - val collected = mutableSetOf() - val bases = mutableSetOf() - - processCallablesByName(name) { function -> - processDirectlyOverriddenCallables(function) { - bases.add(it) - ProcessorAction.NEXT - } - - if (function !in bases) { - collected.add(function) - } - } - - return collected.filter { it !in bases } -} - -fun FirTypeScope.collectLeafFunctionsByName(name: Name): List = - collectLeafCallablesByName(name, ::processFunctionsByName, ::processDirectlyOverriddenFunctions) - -fun FirTypeScope.collectLeafPropertiesByName(name: Name): List> = - collectLeafCallablesByName(name, ::processPropertiesByName) { variable, process -> - if (variable is FirPropertySymbol) { - processDirectlyOverriddenProperties(variable, process) - } - } - -fun FirTypeScope.collectLeafFunctions(): List = buildList { - for (name in getCallableNames()) { - this += collectLeafFunctionsByName(name) - } -} - -fun FirTypeScope.collectLeafProperties(): List> = buildList { - for (name in getCallableNames()) { - this += collectLeafPropertiesByName(name) - } -} - fun FirContainingNamesAwareScope.collectAllProperties(): Collection> { return mutableListOf>().apply { processAllProperties(this::add) diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.fir.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.fir.kt deleted file mode 100644 index e30ce2cc601..00000000000 --- a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.fir.kt +++ /dev/null @@ -1,6 +0,0 @@ -enum class E { - ENTRY; - - fun getDeclaringClass() {} - fun finalize() {} -} diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt index d333d24e91d..609ba57c374 100644 --- a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt +++ b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt @@ -1,3 +1,4 @@ +// FIR_IDENTICAL enum class E { ENTRY;