[FIR] Use the proper `processAll*` functions for CONFLICTING_OVERLOADS

The `*leaf*` functions were
introduced due to my false
assumption. The normal processing
functions only collect leafs
already. `*leaf*`s are bad, because
they don't cache anything.

The change in
AbstractFirOverrideScope reflects
KT-63290, and is needed to avoid
duplicate `CONFLICTING_OVERLOADS`
and `VIRTUAL_MEMBER_HIDDEN`.
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 7f64228..9592936 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 @@
 
         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 @@
 
         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 0a5cc66..7f998f75 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 @@
         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 5806051..1fbcf6f 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 @@
     }
 }
 
-inline fun <reified T : FirCallableSymbol<*>> collectLeafCallablesByName(
-    name: Name,
-    processCallablesByName: (Name, (T) -> Unit) -> Unit,
-    crossinline processDirectlyOverriddenCallables: (T, (T) -> ProcessorAction) -> Unit,
-): List<T> {
-    val collected = mutableSetOf<T>()
-    val bases = mutableSetOf<T>()
-
-    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<FirNamedFunctionSymbol> =
-    collectLeafCallablesByName(name, ::processFunctionsByName, ::processDirectlyOverriddenFunctions)
-
-fun FirTypeScope.collectLeafPropertiesByName(name: Name): List<FirVariableSymbol<*>> =
-    collectLeafCallablesByName(name, ::processPropertiesByName) { variable, process ->
-        if (variable is FirPropertySymbol) {
-            processDirectlyOverriddenProperties(variable, process)
-        }
-    }
-
-fun FirTypeScope.collectLeafFunctions(): List<FirNamedFunctionSymbol> = buildList {
-    for (name in getCallableNames()) {
-        this += collectLeafFunctionsByName(name)
-    }
-}
-
-fun FirTypeScope.collectLeafProperties(): List<FirVariableSymbol<*>> = buildList {
-    for (name in getCallableNames()) {
-        this += collectLeafPropertiesByName(name)
-    }
-}
-
 fun FirContainingNamesAwareScope.collectAllProperties(): Collection<FirVariableSymbol<*>> {
     return mutableListOf<FirVariableSymbol<*>>().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 e30ce2c..0000000
--- a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.fir.kt
+++ /dev/null
@@ -1,6 +0,0 @@
-enum class E {
-    ENTRY;
-
-    fun <!VIRTUAL_MEMBER_HIDDEN!>getDeclaringClass<!>() {}
-    <!ACCIDENTAL_OVERRIDE!>fun <!VIRTUAL_MEMBER_HIDDEN!>finalize<!>() {}<!>
-}
diff --git a/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt b/compiler/testData/diagnostics/testsWithJvmBackend/duplicateJvmSignature/finalMembersFromBuiltIns/enumMembers.kt
index d333d24..609ba57 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;