[FIR] Cleanup FIR modules. Part 7 (scopes package)
This commit is contained in:
@@ -26,14 +26,6 @@ class KotlinScopeProvider(
|
|||||||
scopeSession: ScopeSession
|
scopeSession: ScopeSession
|
||||||
) -> FirScope = { _, declaredMemberScope, _, _ -> declaredMemberScope }
|
) -> FirScope = { _, declaredMemberScope, _, _ -> declaredMemberScope }
|
||||||
) : FirScopeProvider() {
|
) : FirScopeProvider() {
|
||||||
|
|
||||||
|
|
||||||
private fun substitutor(symbol: FirRegularClassSymbol, type: ConeClassLikeType, useSiteSession: FirSession): ConeSubstitutor {
|
|
||||||
if (type.typeArguments.isEmpty()) return ConeSubstitutor.Empty
|
|
||||||
val originalSubstitution = createSubstitution(symbol.fir.typeParameters, type.typeArguments, useSiteSession)
|
|
||||||
return substitutorByMap(originalSubstitution)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getUseSiteMemberScope(
|
override fun getUseSiteMemberScope(
|
||||||
klass: FirClass<*>,
|
klass: FirClass<*>,
|
||||||
useSiteSession: FirSession,
|
useSiteSession: FirSession,
|
||||||
@@ -69,6 +61,12 @@ class KotlinScopeProvider(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun substitutor(symbol: FirRegularClassSymbol, type: ConeClassLikeType, useSiteSession: FirSession): ConeSubstitutor {
|
||||||
|
if (type.typeArguments.isEmpty()) return ConeSubstitutor.Empty
|
||||||
|
val originalSubstitution = createSubstitution(symbol.fir.typeParameters, type.typeArguments, useSiteSession)
|
||||||
|
return substitutorByMap(originalSubstitution)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getStaticMemberScopeForCallables(
|
override fun getStaticMemberScopeForCallables(
|
||||||
klass: FirClass<*>,
|
klass: FirClass<*>,
|
||||||
useSiteSession: FirSession,
|
useSiteSession: FirSession,
|
||||||
|
|||||||
@@ -61,4 +61,3 @@ private fun doCreateImportingScopes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val PACKAGE_MEMBER = scopeSessionKey<FqName, FirPackageMemberScope>()
|
private val PACKAGE_MEMBER = scopeSessionKey<FqName, FirPackageMemberScope>()
|
||||||
|
|
||||||
|
|||||||
+9
-5
@@ -56,12 +56,10 @@ class FirClassSubstitutionScope(
|
|||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
useSiteMemberScope.processFunctionsByName(name) process@{ original ->
|
useSiteMemberScope.processFunctionsByName(name) process@{ original ->
|
||||||
|
|
||||||
val function = fakeOverrideFunctions.getOrPut(original) { createFakeOverrideFunction(original) }
|
val function = fakeOverrideFunctions.getOrPut(original) { createFakeOverrideFunction(original) }
|
||||||
processor(function)
|
processor(function)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return super.processFunctionsByName(name, processor)
|
return super.processFunctionsByName(name, processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +136,11 @@ class FirClassSubstitutionScope(
|
|||||||
return original
|
return original
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Member functions can't capture type parameters, so
|
||||||
|
* it's safe to cast newTypeParameters to List<FirTypeParameter>
|
||||||
|
*/
|
||||||
|
@Suppress("UNCHECKED_CAST")
|
||||||
return createFakeOverrideFunction(
|
return createFakeOverrideFunction(
|
||||||
session,
|
session,
|
||||||
member,
|
member,
|
||||||
@@ -243,6 +246,10 @@ class FirClassSubstitutionScope(
|
|||||||
return original
|
return original
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Member properties can't capture type parameters, so
|
||||||
|
* it's safe to cast newTypeParameters to List<FirTypeParameter>
|
||||||
|
*/
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return createFakeOverrideProperty(
|
return createFakeOverrideProperty(
|
||||||
session,
|
session,
|
||||||
@@ -350,7 +357,6 @@ class FirClassSubstitutionScope(
|
|||||||
typeParameters += newTypeParameters
|
typeParameters += newTypeParameters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createFakeOverrideFunction(
|
fun createFakeOverrideFunction(
|
||||||
@@ -479,13 +485,11 @@ class FirClassSubstitutionScope(
|
|||||||
typeParameters += newTypeParameters
|
typeParameters += newTypeParameters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
override fun processDeclaredConstructors(processor: (FirConstructorSymbol) -> Unit) {
|
||||||
useSiteMemberScope.processDeclaredConstructors process@{ original ->
|
useSiteMemberScope.processDeclaredConstructors process@{ original ->
|
||||||
|
|
||||||
val constructor = fakeOverrideConstructors.getOrPut(original) { createFakeOverrideConstructor(original) }
|
val constructor = fakeOverrideConstructors.getOrPut(original) { createFakeOverrideConstructor(original) }
|
||||||
processor(constructor)
|
processor(constructor)
|
||||||
}
|
}
|
||||||
|
|||||||
-3
@@ -26,7 +26,6 @@ class FirClassUseSiteMemberScope(
|
|||||||
processor(it)
|
processor(it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
superTypesScope.processPropertiesByName(name) {
|
superTypesScope.processPropertiesByName(name) {
|
||||||
val overriddenBy = it.getOverridden(seen)
|
val overriddenBy = it.getOverridden(seen)
|
||||||
if (overriddenBy == null) {
|
if (overriddenBy == null) {
|
||||||
@@ -35,5 +34,3 @@ class FirClassUseSiteMemberScope(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
-1
@@ -89,4 +89,3 @@ fun lazyNestedClassifierScope(
|
|||||||
if (existingNames.isEmpty()) return null
|
if (existingNames.isEmpty()) return null
|
||||||
return FirLazyNestedClassifierScope(classId, existingNames, symbolProvider)
|
return FirLazyNestedClassifierScope(classId, existingNames, symbolProvider)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-1
@@ -15,7 +15,6 @@ class FirExplicitSimpleImportingScope(
|
|||||||
session: FirSession,
|
session: FirSession,
|
||||||
scopeSession: ScopeSession
|
scopeSession: ScopeSession
|
||||||
) : FirAbstractSimpleImportingScope(session, scopeSession) {
|
) : FirAbstractSimpleImportingScope(session, scopeSession) {
|
||||||
|
|
||||||
override val simpleImports =
|
override val simpleImports =
|
||||||
imports.filterIsInstance<FirResolvedImport>()
|
imports.filterIsInstance<FirResolvedImport>()
|
||||||
.filter { !it.isAllUnder && it.importedName != null }
|
.filter { !it.isAllUnder && it.importedName != null }
|
||||||
|
|||||||
+2
-3
@@ -33,7 +33,6 @@ import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
|
|
||||||
class FirIntegerLiteralTypeScope(private val session: FirSession, val isUnsigned: Boolean) : FirTypeScope() {
|
class FirIntegerLiteralTypeScope(private val session: FirSession, val isUnsigned: Boolean) : FirTypeScope() {
|
||||||
sealed class ILTKey {
|
sealed class ILTKey {
|
||||||
object Signed : ILTKey()
|
object Signed : ILTKey()
|
||||||
@@ -48,6 +47,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession, val isUnsigned
|
|||||||
val SCOPE_SESSION_KEY = scopeSessionKey<ILTKey, FirTypeScope>()
|
val SCOPE_SESSION_KEY = scopeSessionKey<ILTKey, FirTypeScope>()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("PrivatePropertyName")
|
||||||
private val BINARY_OPERATOR_SYMBOLS = BINARY_OPERATOR_NAMES.map { name ->
|
private val BINARY_OPERATOR_SYMBOLS = BINARY_OPERATOR_NAMES.map { name ->
|
||||||
name to FirNamedFunctionSymbol(CallableId(name)).apply {
|
name to FirNamedFunctionSymbol(CallableId(name)).apply {
|
||||||
createFirFunction(name, this).apply {
|
createFirFunction(name, this).apply {
|
||||||
@@ -68,6 +68,7 @@ class FirIntegerLiteralTypeScope(private val session: FirSession, val isUnsigned
|
|||||||
}
|
}
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
|
||||||
|
@Suppress("PrivatePropertyName")
|
||||||
private val UNARY_OPERATOR_SYMBOLS = UNARY_OPERATOR_NAMES.map { name ->
|
private val UNARY_OPERATOR_SYMBOLS = UNARY_OPERATOR_NAMES.map { name ->
|
||||||
name to FirNamedFunctionSymbol(CallableId(name)).apply { createFirFunction(name, this) }
|
name to FirNamedFunctionSymbol(CallableId(name)).apply { createFirFunction(name, this) }
|
||||||
}.toMap()
|
}.toMap()
|
||||||
@@ -85,7 +86,6 @@ class FirIntegerLiteralTypeScope(private val session: FirSession, val isUnsigned
|
|||||||
resolvePhase = FirResolvePhase.BODY_RESOLVE
|
resolvePhase = FirResolvePhase.BODY_RESOLVE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
val symbol = BINARY_OPERATOR_SYMBOLS[name]
|
val symbol = BINARY_OPERATOR_SYMBOLS[name]
|
||||||
?: UNARY_OPERATOR_SYMBOLS[name]
|
?: UNARY_OPERATOR_SYMBOLS[name]
|
||||||
@@ -165,4 +165,3 @@ class FirILTTypeRefPlaceHolder(
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -74,6 +74,6 @@ class FirIntegerOperatorCallBuilder : FirQualifiedAccessBuilder, FirCallBuilder,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline fun buildFunctionCall(init: FirIntegerOperatorCallBuilder.() -> Unit): FirIntegerOperatorCall {
|
inline fun buildIntegerOperatorFunctionCall(init: FirIntegerOperatorCallBuilder.() -> Unit): FirIntegerOperatorCall {
|
||||||
return FirIntegerOperatorCallBuilder().apply(init).build()
|
return FirIntegerOperatorCallBuilder().apply(init).build()
|
||||||
}
|
}
|
||||||
-1
@@ -20,7 +20,6 @@ class FirLazyNestedClassifierScope(
|
|||||||
private val existingNames: List<Name>,
|
private val existingNames: List<Name>,
|
||||||
private val symbolProvider: FirSymbolProvider
|
private val symbolProvider: FirSymbolProvider
|
||||||
) : FirScope() {
|
) : FirScope() {
|
||||||
|
|
||||||
override fun processClassifiersByNameWithSubstitution(
|
override fun processClassifiersByNameWithSubstitution(
|
||||||
name: Name,
|
name: Name,
|
||||||
processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit
|
processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit
|
||||||
|
|||||||
@@ -19,14 +19,10 @@ import org.jetbrains.kotlin.fir.symbols.impl.*
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirLocalScope private constructor(
|
class FirLocalScope private constructor(
|
||||||
properties: PersistentMap<Name, FirVariableSymbol<*>>,
|
val properties: PersistentMap<Name, FirVariableSymbol<*>>,
|
||||||
functions: PersistentMultimap<Name, FirFunctionSymbol<*>>,
|
val functions: PersistentMultimap<Name, FirFunctionSymbol<*>>,
|
||||||
classes: PersistentMap<Name, FirRegularClassSymbol>
|
val classes: PersistentMap<Name, FirRegularClassSymbol>
|
||||||
) : FirScope() {
|
) : FirScope() {
|
||||||
val properties: PersistentMap<Name, FirVariableSymbol<*>> = properties
|
|
||||||
val functions: PersistentMultimap<Name, FirFunctionSymbol<*>> = functions
|
|
||||||
val classes: PersistentMap<Name, FirRegularClassSymbol> = classes
|
|
||||||
|
|
||||||
constructor() : this(persistentMapOf(), PersistentMultimap(), persistentMapOf())
|
constructor() : this(persistentMapOf(), PersistentMultimap(), persistentMapOf())
|
||||||
|
|
||||||
fun storeClass(klass: FirRegularClass): FirLocalScope {
|
fun storeClass(klass: FirRegularClass): FirLocalScope {
|
||||||
|
|||||||
+3
-1
@@ -8,7 +8,9 @@ package org.jetbrains.kotlin.fir.scopes.impl
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||||
import org.jetbrains.kotlin.fir.scopes.FirTypeParameterScope
|
import org.jetbrains.kotlin.fir.scopes.FirTypeParameterScope
|
||||||
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirMemberTypeParameterScope(callableMember: FirMemberDeclaration) : FirTypeParameterScope() {
|
class FirMemberTypeParameterScope(callableMember: FirMemberDeclaration) : FirTypeParameterScope() {
|
||||||
override val typeParameters = callableMember.typeParameters.filterIsInstance<FirTypeParameter>().groupBy { it.name }
|
override val typeParameters: Map<Name, List<FirTypeParameter>> =
|
||||||
|
callableMember.typeParameters.filterIsInstance<FirTypeParameter>().groupBy { it.name }
|
||||||
}
|
}
|
||||||
-1
@@ -14,7 +14,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirNestedClassifierScope(val klass: FirClass<*>) : FirScope() {
|
class FirNestedClassifierScope(val klass: FirClass<*>) : FirScope() {
|
||||||
|
|
||||||
private val classIndex: Map<Name, FirRegularClassSymbol> = run {
|
private val classIndex: Map<Name, FirRegularClassSymbol> = run {
|
||||||
val result = mutableMapOf<Name, FirRegularClassSymbol>()
|
val result = mutableMapOf<Name, FirRegularClassSymbol>()
|
||||||
for (declaration in klass.declarations) {
|
for (declaration in klass.declarations) {
|
||||||
|
|||||||
+2
-6
@@ -15,12 +15,9 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirPackageMemberScope(val fqName: FqName, val session: FirSession) : FirScope() {
|
class FirPackageMemberScope(val fqName: FqName, val session: FirSession) : FirScope() {
|
||||||
|
|
||||||
private val symbolProvider = session.firSymbolProvider
|
private val symbolProvider = session.firSymbolProvider
|
||||||
|
private val classifierCache: MutableMap<Name, FirClassifierSymbol<*>?> = mutableMapOf()
|
||||||
private val classifierCache = mutableMapOf<Name, FirClassifierSymbol<*>?>()
|
private val callableCache: MutableMap<Name, List<FirCallableSymbol<*>>> = mutableMapOf()
|
||||||
|
|
||||||
private val callableCache = mutableMapOf<Name, List<FirCallableSymbol<*>>>()
|
|
||||||
|
|
||||||
override fun processClassifiersByNameWithSubstitution(
|
override fun processClassifiersByNameWithSubstitution(
|
||||||
name: Name,
|
name: Name,
|
||||||
@@ -28,7 +25,6 @@ class FirPackageMemberScope(val fqName: FqName, val session: FirSession) : FirSc
|
|||||||
) {
|
) {
|
||||||
if (name.asString().isEmpty()) return
|
if (name.asString().isEmpty()) return
|
||||||
|
|
||||||
|
|
||||||
val symbol = classifierCache.getOrPut(name) {
|
val symbol = classifierCache.getOrPut(name) {
|
||||||
val unambiguousFqName = ClassId(fqName, name)
|
val unambiguousFqName = ClassId(fqName, name)
|
||||||
symbolProvider.getClassLikeSymbolByFqName(unambiguousFqName)
|
symbolProvider.getClassLikeSymbolByFqName(unambiguousFqName)
|
||||||
|
|||||||
-2
@@ -15,7 +15,6 @@ import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
|||||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||||
|
|
||||||
class FirStandardOverrideChecker(session: FirSession) : FirAbstractOverrideChecker() {
|
class FirStandardOverrideChecker(session: FirSession) : FirAbstractOverrideChecker() {
|
||||||
|
|
||||||
private val context: ConeTypeContext = session.typeContext
|
private val context: ConeTypeContext = session.typeContext
|
||||||
|
|
||||||
private fun isEqualTypes(substitutedCandidateType: ConeKotlinType, substitutedBaseType: ConeKotlinType): Boolean {
|
private fun isEqualTypes(substitutedCandidateType: ConeKotlinType, substitutedBaseType: ConeKotlinType): Boolean {
|
||||||
@@ -114,7 +113,6 @@ class FirStandardOverrideChecker(session: FirSession) : FirAbstractOverrideCheck
|
|||||||
return overrideCandidate.valueParameters.zip(baseDeclaration.valueParameters).all { (memberParam, selfParam) ->
|
return overrideCandidate.valueParameters.zip(baseDeclaration.valueParameters).all { (memberParam, selfParam) ->
|
||||||
isEqualTypes(memberParam.returnTypeRef, selfParam.returnTypeRef, substitutor)
|
isEqualTypes(memberParam.returnTypeRef, selfParam.returnTypeRef, substitutor)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun isOverriddenProperty(
|
override fun isOverriddenProperty(
|
||||||
|
|||||||
@@ -16,15 +16,11 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
class FirStaticScope(private val delegateScope: FirScope) : FirScope() {
|
class FirStaticScope(private val delegateScope: FirScope) : FirScope() {
|
||||||
|
|
||||||
override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) {
|
override fun processClassifiersByNameWithSubstitution(name: Name, processor: (FirClassifierSymbol<*>, ConeSubstitutor) -> Unit) {
|
||||||
delegateScope.processClassifiersByNameWithSubstitution(name, processor)
|
delegateScope.processClassifiersByNameWithSubstitution(name, processor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processFunctionsByName(
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
name: Name,
|
|
||||||
processor: (FirFunctionSymbol<*>) -> Unit
|
|
||||||
) {
|
|
||||||
delegateScope.processFunctionsByName(name) {
|
delegateScope.processFunctionsByName(name) {
|
||||||
if ((it.fir as? FirSimpleFunction)?.isStatic == true) {
|
if ((it.fir as? FirSimpleFunction)?.isStatic == true) {
|
||||||
processor(it)
|
processor(it)
|
||||||
@@ -32,10 +28,7 @@ class FirStaticScope(private val delegateScope: FirScope) : FirScope() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun processPropertiesByName(
|
override fun processPropertiesByName(name: Name, processor: (FirVariableSymbol<*>) -> Unit) {
|
||||||
name: Name,
|
|
||||||
processor: (FirVariableSymbol<*>) -> Unit
|
|
||||||
) {
|
|
||||||
delegateScope.processPropertiesByName(name) {
|
delegateScope.processPropertiesByName(name) {
|
||||||
if ((it.fir as? FirCallableMemberDeclaration<*>)?.isStatic == true) {
|
if ((it.fir as? FirCallableMemberDeclaration<*>)?.isStatic == true) {
|
||||||
processor(it)
|
processor(it)
|
||||||
|
|||||||
+10
-21
@@ -32,16 +32,13 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
overrideChecker: FirOverrideChecker,
|
overrideChecker: FirOverrideChecker,
|
||||||
private val scopes: List<FirTypeScope>,
|
private val scopes: List<FirTypeScope>,
|
||||||
) : AbstractFirOverrideScope(session, overrideChecker) {
|
) : AbstractFirOverrideScope(session, overrideChecker) {
|
||||||
|
private val absentFunctions: MutableSet<Name> = mutableSetOf()
|
||||||
private val absentFunctions = mutableSetOf<Name>()
|
private val absentProperties: MutableSet<Name> = mutableSetOf()
|
||||||
|
private val absentClassifiers: MutableSet<Name> = mutableSetOf()
|
||||||
private val absentProperties = mutableSetOf<Name>()
|
|
||||||
|
|
||||||
private val absentClassifiers = mutableSetOf<Name>()
|
|
||||||
|
|
||||||
private val typeContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session)
|
private val typeContext = ConeTypeCheckerContext(isErrorTypeEqualsToAnything = false, isStubTypeEqualsToAnything = false, session)
|
||||||
|
|
||||||
private val overriddenSymbols = mutableMapOf<FirCallableSymbol<*>, Collection<FirCallableSymbol<*>>>()
|
private val overriddenSymbols: MutableMap<FirCallableSymbol<*>, Collection<FirCallableSymbol<*>>> = mutableMapOf()
|
||||||
|
|
||||||
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
override fun processFunctionsByName(name: Name, processor: (FirFunctionSymbol<*>) -> Unit) {
|
||||||
if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) {
|
if (!processCallablesByName(name, processor, absentFunctions, FirScope::processFunctionsByName)) {
|
||||||
@@ -87,7 +84,6 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
processor(member)
|
processor(member)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,10 +101,8 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <D : FirCallableSymbol<*>> selectMostSpecificMember(
|
private fun <D : FirCallableSymbol<*>> selectMostSpecificMember(overridables: Collection<D>): D {
|
||||||
overridables: Collection<D>
|
require(overridables.isNotEmpty()) { "Should have at least one overridable symbol" }
|
||||||
): D {
|
|
||||||
require(overridables.isNotEmpty()) { "Should have at least one overridable descriptor" }
|
|
||||||
if (overridables.size == 1) {
|
if (overridables.size == 1) {
|
||||||
return overridables.first()
|
return overridables.first()
|
||||||
}
|
}
|
||||||
@@ -126,19 +120,15 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
when {
|
return when {
|
||||||
candidates.isEmpty() -> {
|
candidates.isEmpty() -> transitivelyMostSpecific
|
||||||
return transitivelyMostSpecific
|
candidates.size == 1 -> candidates.first()
|
||||||
}
|
|
||||||
candidates.size == 1 -> {
|
|
||||||
return candidates.first()
|
|
||||||
}
|
|
||||||
else -> {
|
else -> {
|
||||||
candidates.firstOrNull {
|
candidates.firstOrNull {
|
||||||
val type = it.fir.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
val type = it.fir.returnTypeRef.coneTypeSafe<ConeKotlinType>()
|
||||||
type != null && type !is ConeFlexibleType
|
type != null && type !is ConeFlexibleType
|
||||||
}?.let { return it }
|
}?.let { return it }
|
||||||
return candidates.first()
|
candidates.first()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +262,6 @@ class FirTypeIntersectionScope private constructor(
|
|||||||
scopes: List<FirTypeScope>
|
scopes: List<FirTypeScope>
|
||||||
): FirTypeScope {
|
): FirTypeScope {
|
||||||
scopes.singleOrNull()?.let { return it }
|
scopes.singleOrNull()?.let { return it }
|
||||||
|
|
||||||
return FirTypeIntersectionScope(session, overrideChecker, scopes)
|
return FirTypeIntersectionScope(session, overrideChecker, scopes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user