FIR: Cache functions in use-site member scope
This commit is contained in:
+24
-9
@@ -27,22 +27,37 @@ abstract class AbstractFirUseSiteMemberScope(
|
|||||||
protected val superTypesScope: FirSuperTypeScope,
|
protected val superTypesScope: FirSuperTypeScope,
|
||||||
protected val declaredMemberScope: FirScope
|
protected val declaredMemberScope: FirScope
|
||||||
) : AbstractFirOverrideScope(session, overrideChecker) {
|
) : AbstractFirOverrideScope(session, overrideChecker) {
|
||||||
|
|
||||||
|
private val functions = hashMapOf<Name, Collection<FirFunctionSymbol<*>>>()
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> ProcessorAction): ProcessorAction {
|
||||||
|
functions.getOrPut(name) {
|
||||||
|
doProcessFunctions(name)
|
||||||
|
}.forEach {
|
||||||
|
if (processor(it) == ProcessorAction.STOP) return ProcessorAction.STOP
|
||||||
|
}
|
||||||
|
|
||||||
|
return ProcessorAction.NEXT
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doProcessFunctions(
|
||||||
|
name: Name
|
||||||
|
): Collection<FirFunctionSymbol<*>> = mutableListOf<FirFunctionSymbol<*>>().apply {
|
||||||
val overrideCandidates = mutableSetOf<FirFunctionSymbol<*>>()
|
val overrideCandidates = mutableSetOf<FirFunctionSymbol<*>>()
|
||||||
if (!declaredMemberScope.processFunctionsByName(name) {
|
if (!declaredMemberScope.processFunctionsByName(name) {
|
||||||
val symbol = processInheritedDefaultParameters(it)
|
val symbol = processInheritedDefaultParameters(it)
|
||||||
overrideCandidates += symbol
|
overrideCandidates += symbol
|
||||||
processor(symbol)
|
add(symbol)
|
||||||
}
|
|
||||||
) return ProcessorAction.STOP
|
|
||||||
|
|
||||||
return superTypesScope.processFunctionsByName(name) {
|
|
||||||
val overriddenBy = it.getOverridden(overrideCandidates)
|
|
||||||
if (overriddenBy == null) {
|
|
||||||
processor(it)
|
|
||||||
} else {
|
|
||||||
ProcessorAction.NEXT
|
ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
|
) return@apply
|
||||||
|
|
||||||
|
superTypesScope.processFunctionsByName(name) {
|
||||||
|
val overriddenBy = it.getOverridden(overrideCandidates)
|
||||||
|
if (overriddenBy == null) {
|
||||||
|
add(it)
|
||||||
|
}
|
||||||
|
ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user