FIR: cache properties in use-site scope properly
This commit is contained in:
committed by
teamcity
parent
f2c734fc02
commit
6eaeada1e6
+11
@@ -22,6 +22,7 @@ abstract class AbstractFirUseSiteMemberScope(
|
||||
) : AbstractFirOverrideScope(session, overrideChecker) {
|
||||
|
||||
private val functions = hashMapOf<Name, Collection<FirNamedFunctionSymbol>>()
|
||||
private val properties = hashMapOf<Name, Collection<FirVariableSymbol<*>>>()
|
||||
val directOverriddenFunctions = hashMapOf<FirNamedFunctionSymbol, Collection<FirNamedFunctionSymbol>>()
|
||||
protected val directOverriddenProperties = hashMapOf<FirPropertySymbol, MutableList<FirPropertySymbol>>()
|
||||
|
||||
@@ -57,6 +58,16 @@ abstract class AbstractFirUseSiteMemberScope(
|
||||
}
|
||||
}
|
||||
|
||||
final override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
properties.getOrPut(name) {
|
||||
doProcessProperties(name)
|
||||
}.forEach {
|
||||
processor(it)
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract fun doProcessProperties(name: Name): Collection<FirVariableSymbol<*>>
|
||||
|
||||
private fun computeDirectOverridden(symbol: FirNamedFunctionSymbol): Collection<FirNamedFunctionSymbol> {
|
||||
val result = mutableListOf<FirNamedFunctionSymbol>()
|
||||
val firSimpleFunction = symbol.fir
|
||||
|
||||
+5
-3
@@ -20,8 +20,9 @@ class FirClassUseSiteMemberScope(
|
||||
declaredMemberScope: FirContainingNamesAwareScope
|
||||
) : AbstractFirUseSiteMemberScope(session, FirStandardOverrideChecker(session), superTypesScope, declaredMemberScope) {
|
||||
|
||||
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||
override fun doProcessProperties(name: Name): Collection<FirVariableSymbol<*>> {
|
||||
val seen = mutableSetOf<FirVariableSymbol<*>>()
|
||||
val result = mutableSetOf<FirVariableSymbol<*>>()
|
||||
declaredMemberScope.processPropertiesByName(name) l@{
|
||||
if (it.isStatic) return@l
|
||||
if (it is FirPropertySymbol) {
|
||||
@@ -29,15 +30,16 @@ class FirClassUseSiteMemberScope(
|
||||
this@FirClassUseSiteMemberScope.directOverriddenProperties[it] = directOverridden
|
||||
}
|
||||
seen += it
|
||||
processor(it)
|
||||
result += it
|
||||
}
|
||||
|
||||
superTypesScope.processPropertiesByName(name) {
|
||||
val overriddenBy = it.getOverridden(seen)
|
||||
if (overriddenBy == null) {
|
||||
processor(it)
|
||||
result += it
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun computeDirectOverridden(property: FirProperty): MutableList<FirPropertySymbol> {
|
||||
|
||||
Reference in New Issue
Block a user