[FIR] Cache callable names in some composite scopes
This commit is contained in:
committed by
teamcityserver
parent
15be38192b
commit
6ef4523555
+4
-2
@@ -53,10 +53,12 @@ class JavaClassUseSiteMemberScope(
|
|||||||
|
|
||||||
private val canUseSpecialGetters: Boolean by lazy { !klass.hasKotlinSuper(session) }
|
private val canUseSpecialGetters: Boolean by lazy { !klass.hasKotlinSuper(session) }
|
||||||
|
|
||||||
override fun getCallableNames(): Set<Name> {
|
private val callableNamesCached by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
return declaredMemberScope.getContainingCallableNamesIfPresent() + superTypesScope.getCallableNames()
|
declaredMemberScope.getContainingCallableNamesIfPresent() + superTypesScope.getCallableNames()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCallableNames(): Set<Name> = callableNamesCached
|
||||||
|
|
||||||
override fun getClassifierNames(): Set<Name> {
|
override fun getClassifierNames(): Set<Name> {
|
||||||
return declaredMemberScope.getContainingClassifierNamesIfPresent() + superTypesScope.getClassifierNames()
|
return declaredMemberScope.getContainingClassifierNamesIfPresent() + superTypesScope.getClassifierNames()
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -22,6 +22,10 @@ abstract class AbstractFirUseSiteMemberScope(
|
|||||||
protected val directOverriddenFunctions = hashMapOf<FirNamedFunctionSymbol, Collection<FirNamedFunctionSymbol>>()
|
protected val directOverriddenFunctions = hashMapOf<FirNamedFunctionSymbol, Collection<FirNamedFunctionSymbol>>()
|
||||||
protected val directOverriddenProperties = hashMapOf<FirPropertySymbol, MutableList<FirPropertySymbol>>()
|
protected val directOverriddenProperties = hashMapOf<FirPropertySymbol, MutableList<FirPropertySymbol>>()
|
||||||
|
|
||||||
|
private val callableNamesCached by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
|
declaredMemberScope.getContainingCallableNamesIfPresent() + superTypesScope.getCallableNames()
|
||||||
|
}
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
||||||
functions.getOrPut(name) {
|
functions.getOrPut(name) {
|
||||||
doProcessFunctions(name)
|
doProcessFunctions(name)
|
||||||
@@ -89,9 +93,7 @@ abstract class AbstractFirUseSiteMemberScope(
|
|||||||
declaredMemberScope.processDeclaredConstructors(processor)
|
declaredMemberScope.processDeclaredConstructors(processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCallableNames(): Set<Name> {
|
override fun getCallableNames(): Set<Name> = callableNamesCached
|
||||||
return declaredMemberScope.getContainingCallableNamesIfPresent() + superTypesScope.getCallableNames()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getClassifierNames(): Set<Name> {
|
override fun getClassifierNames(): Set<Name> {
|
||||||
return declaredMemberScope.getContainingClassifierNamesIfPresent() + superTypesScope.getClassifierNames()
|
return declaredMemberScope.getContainingClassifierNamesIfPresent() + superTypesScope.getClassifierNames()
|
||||||
|
|||||||
+5
-3
@@ -42,6 +42,10 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
|
|
||||||
private val intersectionOverrides: MutableMap<FirCallableSymbol<*>, MemberWithBaseScope<out FirCallableSymbol<*>>> = mutableMapOf()
|
private val intersectionOverrides: MutableMap<FirCallableSymbol<*>, MemberWithBaseScope<out FirCallableSymbol<*>>> = mutableMapOf()
|
||||||
|
|
||||||
|
private val callableNamesCached by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||||
|
scopes.flatMapTo(mutableSetOf()) { it.getCallableNames() }
|
||||||
|
}
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirNamedFunctionSymbol) -> Unit) {
|
||||||
if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) {
|
if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) {
|
||||||
super.processFunctionsByName(name, processor)
|
super.processFunctionsByName(name, processor)
|
||||||
@@ -540,9 +544,7 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
return ProcessorAction.NEXT
|
return ProcessorAction.NEXT
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getCallableNames(): Set<Name> {
|
override fun getCallableNames(): Set<Name> = callableNamesCached
|
||||||
return scopes.flatMapTo(mutableSetOf()) { it.getCallableNames() }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getClassifierNames(): Set<Name> {
|
override fun getClassifierNames(): Set<Name> {
|
||||||
return scopes.flatMapTo(hashSetOf()) { it.getClassifierNames() }
|
return scopes.flatMapTo(hashSetOf()) { it.getClassifierNames() }
|
||||||
|
|||||||
Reference in New Issue
Block a user