[FIR] Move collecting classifiers from type intersection scope to context
This commit is contained in:
+6
-16
@@ -68,24 +68,14 @@ class FirTypeIntersectionScope private constructor(
|
||||
if (name in absentClassifiers) {
|
||||
return
|
||||
}
|
||||
val accepted = HashSet<FirClassifierSymbol<*>>()
|
||||
val pending = mutableListOf<FirClassifierSymbol<*>>()
|
||||
var empty = true
|
||||
for (scope in scopes) {
|
||||
scope.processClassifiersByNameWithSubstitution(name) { symbol, substitution ->
|
||||
empty = false
|
||||
if (symbol !in accepted) {
|
||||
pending += symbol
|
||||
processor(symbol, substitution)
|
||||
}
|
||||
}
|
||||
accepted += pending
|
||||
pending.clear()
|
||||
}
|
||||
if (empty) {
|
||||
val classifiersWithSubstitution = intersectionContext.collectClassifiers(name)
|
||||
if (classifiersWithSubstitution.isEmpty()) {
|
||||
absentClassifiers += name
|
||||
return
|
||||
}
|
||||
for ((symbol, substitution) in classifiersWithSubstitution) {
|
||||
processor(symbol, substitution)
|
||||
}
|
||||
super.processClassifiersByNameWithSubstitution(name, processor)
|
||||
}
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
+19
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.modality
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirIntersectionOverrideStorage.ContextForIntersectionOverrideConstruction
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
@@ -46,6 +47,24 @@ class FirTypeIntersectionScopeContext(
|
||||
) : this(chosenSymbol, listOf(overriddenMember))
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
fun collectClassifiers(name: Name): List<Pair<FirClassifierSymbol<*>, ConeSubstitutor>> {
|
||||
val accepted = HashSet<FirClassifierSymbol<*>>()
|
||||
val pending = mutableListOf<FirClassifierSymbol<*>>()
|
||||
val result = mutableListOf<Pair<FirClassifierSymbol<*>, ConeSubstitutor>>()
|
||||
for (scope in scopes) {
|
||||
scope.processClassifiersByNameWithSubstitution(name) { symbol, substitution ->
|
||||
if (symbol !in accepted) {
|
||||
pending += symbol
|
||||
result += symbol to substitution
|
||||
}
|
||||
}
|
||||
accepted += pending
|
||||
pending.clear()
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <D : FirCallableSymbol<*>> collectCallables(
|
||||
name: Name,
|
||||
|
||||
Reference in New Issue
Block a user