[FIR] Extract duplicated code of processing classifiers from intersection scope
This commit is contained in:
+1
-10
@@ -198,16 +198,7 @@ abstract class AbstractFirUseSiteMemberScope(
|
||||
|
||||
override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) {
|
||||
declaredMemberScope.processClassifiersByNameWithSubstitution(name, processor)
|
||||
|
||||
if (name in absentClassifiersFromSupertypes) return
|
||||
val classifiers = supertypeScopeContext.collectClassifiers(name)
|
||||
if (classifiers.isEmpty()) {
|
||||
absentClassifiersFromSupertypes += name
|
||||
return
|
||||
}
|
||||
for ((symbol, substitution) in classifiers) {
|
||||
processor(symbol, substitution)
|
||||
}
|
||||
supertypeScopeContext.processClassifiersByNameWithSubstitution(name, absentClassifiersFromSupertypes, processor)
|
||||
}
|
||||
|
||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||
|
||||
+1
-11
@@ -63,17 +63,7 @@ class FirTypeIntersectionScope private constructor(
|
||||
}
|
||||
|
||||
override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) {
|
||||
if (name in absentClassifiers) {
|
||||
return
|
||||
}
|
||||
val classifiersWithSubstitution = intersectionContext.collectClassifiers(name)
|
||||
if (classifiersWithSubstitution.isEmpty()) {
|
||||
absentClassifiers += name
|
||||
return
|
||||
}
|
||||
for ((symbol, substitution) in classifiersWithSubstitution) {
|
||||
processor(symbol, substitution)
|
||||
}
|
||||
intersectionContext.processClassifiersByNameWithSubstitution(name, absentClassifiers, processor)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
+17
-2
@@ -78,8 +78,23 @@ class FirTypeIntersectionScopeContext(
|
||||
}
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun collectClassifiers(name: Name): List<Pair<FirClassifierSymbol<*>, ConeSubstitutor>> {
|
||||
fun processClassifiersByNameWithSubstitution(
|
||||
name: Name,
|
||||
absentClassifierNames: MutableSet<Name>,
|
||||
processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit
|
||||
) {
|
||||
if (name in absentClassifierNames) return
|
||||
val classifiers = collectClassifiers(name)
|
||||
if (classifiers.isEmpty()) {
|
||||
absentClassifierNames += name
|
||||
return
|
||||
}
|
||||
for ((symbol, substitution) in classifiers) {
|
||||
processor(symbol, substitution)
|
||||
}
|
||||
}
|
||||
|
||||
private fun collectClassifiers(name: Name): List<Pair<FirClassifierSymbol<*>, ConeSubstitutor>> {
|
||||
val accepted = HashSet<FirClassifierSymbol<*>>()
|
||||
val pending = mutableListOf<FirClassifierSymbol<*>>()
|
||||
val result = mutableListOf<Pair<FirClassifierSymbol<*>, ConeSubstitutor>>()
|
||||
|
||||
Reference in New Issue
Block a user