FIR: Minor. Clarify some names at FirTypeIntersectionScopeContext
This commit is contained in:
+11
-11
@@ -120,7 +120,7 @@ class JavaClassUseSiteMemberScope(
|
||||
* 2. Field from some java superclass (only one, if class have more than one superclass then we can choose
|
||||
* just one field because this is incorrect code anyway)
|
||||
*/
|
||||
val fromSupertypes = supertypeScopeContext.collectCallables(name, FirScope::processPropertiesByName)
|
||||
val fromSupertypes = supertypeScopeContext.collectIntersectionResultsForCallables(name, FirScope::processPropertiesByName)
|
||||
|
||||
val (fieldsFromSupertype, propertiesFromSupertypes) = fromSupertypes.partition {
|
||||
it is ResultOfIntersection.SingleMember && it.chosenSymbol is FirFieldSymbol
|
||||
@@ -251,7 +251,7 @@ class JavaClassUseSiteMemberScope(
|
||||
private fun FirNamedFunctionSymbol.doesOverrideRenamedBuiltins(): Boolean {
|
||||
// e.g. 'removeAt' or 'toInt'
|
||||
val builtinName = SpecialGenericSignatures.getBuiltinFunctionNamesByJvmName(name) ?: return false
|
||||
val builtinSpecialFromSuperTypes = supertypeScopeContext.collectMembersByScope(builtinName, FirScope::processFunctionsByName)
|
||||
val builtinSpecialFromSuperTypes = supertypeScopeContext.collectMembersGroupedByScope(builtinName, FirScope::processFunctionsByName)
|
||||
.flatMap { (scope, symbols) ->
|
||||
symbols.filter { it.doesOverrideBuiltinWithDifferentJvmName(scope, session) }
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class JavaClassUseSiteMemberScope(
|
||||
*/
|
||||
private fun FirNamedFunctionSymbol.shouldBeVisibleAsOverrideOfBuiltInWithErasedValueParameters(): Boolean {
|
||||
if (!name.sameAsBuiltinMethodWithErasedValueParameters) return false
|
||||
val candidatesToOverride = supertypeScopeContext.collectMembersByScope(name, FirScope::processFunctionsByName)
|
||||
val candidatesToOverride = supertypeScopeContext.collectMembersGroupedByScope(name, FirScope::processFunctionsByName)
|
||||
.flatMap { (scope, symbols) ->
|
||||
symbols.mapNotNull {
|
||||
BuiltinMethodsWithSpecialGenericSignature.getOverriddenBuiltinFunctionWithErasedValueParametersInJava(it, scope)
|
||||
@@ -320,7 +320,7 @@ class JavaClassUseSiteMemberScope(
|
||||
collectDeclaredFunctions(name, result)
|
||||
val explicitlyDeclaredFunctions = result.toSet()
|
||||
|
||||
val functionsWithScopeFromSupertypes = supertypeScopeContext.collectMembersByScope(name, FirScope::processFunctionsByName)
|
||||
val functionsWithScopeFromSupertypes = supertypeScopeContext.collectMembersGroupedByScope(name, FirScope::processFunctionsByName)
|
||||
|
||||
if (
|
||||
!name.sameAsRenamedInJvmBuiltin &&
|
||||
@@ -337,13 +337,13 @@ class JavaClassUseSiteMemberScope(
|
||||
}
|
||||
|
||||
private fun processSpecialFunctions(
|
||||
naturalName: Name,
|
||||
requestedName: Name,
|
||||
explicitlyDeclaredFunctionsWithNaturalName: Collection<FirNamedFunctionSymbol>,
|
||||
functionsFromSupertypesWithNaturalName: MembersByScope<FirNamedFunctionSymbol>, // candidates for override
|
||||
functionsFromSupertypesWithRequestedName: MembersByScope<FirNamedFunctionSymbol>, // candidates for override
|
||||
destination: MutableCollection<FirNamedFunctionSymbol>
|
||||
) {
|
||||
val resultsOfIntersectionToSaveInCache = mutableListOf<ResultOfIntersection<FirNamedFunctionSymbol>>()
|
||||
val list = supertypeScopeContext.collectCallablesImpl(functionsFromSupertypesWithNaturalName)
|
||||
val list = supertypeScopeContext.convertGroupedCallablesToIntersectionResults(functionsFromSupertypesWithRequestedName)
|
||||
for (resultOfIntersectionWithNaturalName in list) {
|
||||
val someSymbolWithNaturalNameFromSuperType = resultOfIntersectionWithNaturalName.extractSomeSymbolFromSuperType()
|
||||
val explicitlyDeclaredFunctionWithNaturalName = explicitlyDeclaredFunctionsWithNaturalName.firstOrNull {
|
||||
@@ -357,7 +357,7 @@ class JavaClassUseSiteMemberScope(
|
||||
jvmName,
|
||||
someSymbolWithNaturalNameFromSuperType,
|
||||
explicitlyDeclaredFunctionWithNaturalName,
|
||||
naturalName,
|
||||
requestedName,
|
||||
resultOfIntersectionWithNaturalName,
|
||||
destination,
|
||||
resultsOfIntersectionToSaveInCache
|
||||
@@ -367,7 +367,7 @@ class JavaClassUseSiteMemberScope(
|
||||
|
||||
if (processOverridesForFunctionsWithErasedValueParameter(
|
||||
resultOfIntersectionWithNaturalName.overriddenMembers,
|
||||
naturalName,
|
||||
requestedName,
|
||||
explicitlyDeclaredFunctionsWithNaturalName,
|
||||
destination,
|
||||
resultOfIntersectionWithNaturalName,
|
||||
@@ -392,7 +392,7 @@ class JavaClassUseSiteMemberScope(
|
||||
}
|
||||
}
|
||||
}
|
||||
functionsFromSupertypes[naturalName] = resultsOfIntersectionToSaveInCache
|
||||
functionsFromSupertypes[requestedName] = resultsOfIntersectionToSaveInCache
|
||||
}
|
||||
|
||||
private fun processOverridesForFunctionsWithErasedValueParameter(
|
||||
@@ -521,7 +521,7 @@ class JavaClassUseSiteMemberScope(
|
||||
overriddenMembers.mapTo(this) { it.baseScope to listOf(it.member) }
|
||||
addAll(renamedFunctionsFromSupertypes)
|
||||
}
|
||||
supertypeScopeContext.collectCallablesImpl(membersByScope)
|
||||
supertypeScopeContext.convertGroupedCallablesToIntersectionResults(membersByScope)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ abstract class AbstractFirUseSiteMemberScope(
|
||||
|
||||
private fun getFunctionsFromSupertypesByName(name: Name): List<ResultOfIntersection<FirNamedFunctionSymbol>> {
|
||||
return functionsFromSupertypes.getOrPut(name) {
|
||||
supertypeScopeContext.collectCallables(name, FirScope::processFunctionsByName)
|
||||
supertypeScopeContext.collectIntersectionResultsForCallables(name, FirScope::processFunctionsByName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ class FirClassUseSiteMemberScope(
|
||||
}
|
||||
|
||||
val fields = mutableListOf<FirFieldSymbol>()
|
||||
val properties = supertypeScopeContext.collectCallables<FirPropertySymbol>(name) { propertyName, processor ->
|
||||
val properties = supertypeScopeContext.collectIntersectionResultsForCallables<FirPropertySymbol>(name) { propertyName, processor ->
|
||||
processPropertiesByName(propertyName) {
|
||||
when (it) {
|
||||
is FirPropertySymbol -> processor(it)
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ class FirTypeIntersectionScope private constructor(
|
||||
return
|
||||
}
|
||||
|
||||
val callablesWithOverridden = intersectionContext.collectCallables(name, processCallables)
|
||||
val callablesWithOverridden = intersectionContext.collectIntersectionResultsForCallables(name, processCallables)
|
||||
|
||||
if (callablesWithOverridden.isEmpty()) {
|
||||
absentNames.add(name)
|
||||
|
||||
+11
-7
@@ -10,7 +10,9 @@ import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.descriptors.Visibility
|
||||
import org.jetbrains.kotlin.fir.*
|
||||
import org.jetbrains.kotlin.fir.caches.*
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.modality
|
||||
import org.jetbrains.kotlin.fir.declarations.utils.visibility
|
||||
@@ -20,7 +22,9 @@ import org.jetbrains.kotlin.fir.scopes.*
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirIntersectionOverrideStorage.ContextForIntersectionOverrideConstruction
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirTypeIntersectionScopeContext.ResultOfIntersection
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.ConeSimpleKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.classId
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
@@ -109,11 +113,11 @@ class FirTypeIntersectionScopeContext(
|
||||
}
|
||||
|
||||
fun collectFunctions(name: Name): List<ResultOfIntersection<FirNamedFunctionSymbol>> {
|
||||
return collectCallables(name, FirScope::processFunctionsByName)
|
||||
return collectIntersectionResultsForCallables(name, FirScope::processFunctionsByName)
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <D : FirCallableSymbol<*>> collectMembersByScope(
|
||||
inline fun <D : FirCallableSymbol<*>> collectMembersGroupedByScope(
|
||||
name: Name,
|
||||
processCallables: FirScope.(Name, (D) -> Unit) -> Unit
|
||||
): MembersByScope<D> {
|
||||
@@ -132,14 +136,14 @@ class FirTypeIntersectionScopeContext(
|
||||
}
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <D : FirCallableSymbol<*>> collectCallables(
|
||||
inline fun <D : FirCallableSymbol<*>> collectIntersectionResultsForCallables(
|
||||
name: Name,
|
||||
processCallables: FirScope.(Name, (D) -> Unit) -> Unit
|
||||
): List<ResultOfIntersection<D>> {
|
||||
return collectCallablesImpl(collectMembersByScope(name, processCallables))
|
||||
return convertGroupedCallablesToIntersectionResults(collectMembersGroupedByScope(name, processCallables))
|
||||
}
|
||||
|
||||
fun <D : FirCallableSymbol<*>> collectCallablesImpl(
|
||||
fun <D : FirCallableSymbol<*>> convertGroupedCallablesToIntersectionResults(
|
||||
membersByScope: List<Pair<FirTypeScope, List<D>>>
|
||||
): List<ResultOfIntersection<D>> {
|
||||
if (membersByScope.isEmpty()) {
|
||||
|
||||
Reference in New Issue
Block a user