[FIR] Use abstract classes for FIR scopes
This commit is contained in:
committed by
Mikhail Glukhikh
parent
810fa9c171
commit
95409b35ca
+1
-1
@@ -40,7 +40,7 @@ import org.jetbrains.kotlin.utils.Jsr305State
|
||||
class JavaClassEnhancementScope(
|
||||
private val session: FirSession,
|
||||
private val useSiteScope: JavaClassUseSiteScope
|
||||
) : FirScope {
|
||||
) : FirScope() {
|
||||
private val owner: FirRegularClass = useSiteScope.symbol.fir
|
||||
|
||||
private val javaTypeParameterStack: JavaTypeParameterStack =
|
||||
|
||||
@@ -26,7 +26,7 @@ class FirSyntheticPropertiesScope(
|
||||
val session: FirSession,
|
||||
private val baseScope: FirScope,
|
||||
private val typeCalculator: ReturnTypeCalculator
|
||||
) : FirScope {
|
||||
) : FirScope() {
|
||||
|
||||
val synthetic: MutableMap<ConeCallableSymbol, ConeVariableSymbol> = mutableMapOf()
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.declarations.FirTypeParameter
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeClassifierSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface FirTypeParameterScope : FirScope {
|
||||
val typeParameters: Map<Name, List<FirTypeParameter>>
|
||||
abstract class FirTypeParameterScope : FirScope() {
|
||||
abstract val typeParameters: Map<Name, List<FirTypeParameter>>
|
||||
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.types.impl.ConeTypeParameterTypeImpl
|
||||
import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
|
||||
abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope {
|
||||
abstract class AbstractFirOverrideScope(val session: FirSession) : FirScope() {
|
||||
//base symbol as key
|
||||
val overrides = mutableMapOf<ConeCallableSymbol, ConeCallableSymbol?>()
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.kotlin.fir.resolve.impl.FirDependenciesSymbolProviderImpl
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
|
||||
abstract class FirAbstractProviderBasedScope(val session: FirSession, lookupInFir: Boolean = true) :
|
||||
FirScope {
|
||||
FirScope() {
|
||||
val provider = when (val symbolProvider = FirSymbolProvider.getInstance(session)) {
|
||||
is FirCompositeSymbolProvider -> symbolProvider.takeIf { !lookupInFir }?.providers?.find {
|
||||
it is FirDependenciesSymbolProviderImpl
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ fun declaredMemberScope(klass: FirRegularClass): FirClassDeclaredMemberScope {
|
||||
.declaredMemberScope(klass)
|
||||
}
|
||||
|
||||
class FirClassDeclaredMemberScope(klass: FirRegularClass) : FirScope {
|
||||
class FirClassDeclaredMemberScope(klass: FirRegularClass) : FirScope() {
|
||||
private val callablesIndex: Map<Name, List<FirCallableSymbol>> = run {
|
||||
val result = mutableMapOf<Name, MutableList<FirCallableSymbol>>()
|
||||
for (declaration in klass.declarations) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ class FirClassSubstitutionScope(
|
||||
private val session: FirSession,
|
||||
private val useSiteScope: FirScope,
|
||||
substitution: Map<ConeTypeParameterSymbol, ConeKotlinType>
|
||||
) : FirScope {
|
||||
) : FirScope() {
|
||||
|
||||
private val fakeOverrides = mutableMapOf<ConeCallableSymbol, ConeCallableSymbol>()
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
class FirCompositeScope(
|
||||
val scopes: MutableList<FirScope>,
|
||||
private val reversedPriority: Boolean = false
|
||||
) : FirScope {
|
||||
) : FirScope() {
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
position: FirPosition,
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.fir.symbols.ConeVariableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirLocalScope : FirScope {
|
||||
class FirLocalScope : FirScope() {
|
||||
|
||||
val properties = mutableMapOf<Name, ConeVariableSymbol>()
|
||||
val functions = mutableMapOf<Name, ConeFunctionSymbol>()
|
||||
|
||||
+1
-1
@@ -8,6 +8,6 @@ package org.jetbrains.kotlin.fir.scopes.impl
|
||||
import org.jetbrains.kotlin.fir.declarations.FirMemberDeclaration
|
||||
import org.jetbrains.kotlin.fir.scopes.FirTypeParameterScope
|
||||
|
||||
class FirMemberTypeParameterScope(callableMember: FirMemberDeclaration) : FirTypeParameterScope {
|
||||
class FirMemberTypeParameterScope(callableMember: FirMemberDeclaration) : FirTypeParameterScope() {
|
||||
override val typeParameters = callableMember.typeParameters.groupBy { it.name }
|
||||
}
|
||||
+1
-1
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
class FirNestedClassifierScope(
|
||||
val classId: ClassId,
|
||||
private val symbolProvider: FirSymbolProvider
|
||||
) : FirScope {
|
||||
) : FirScope() {
|
||||
|
||||
override fun processClassifiersByName(
|
||||
name: Name,
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirScope {
|
||||
class FirSelfImportingScope(val fqName: FqName, val session: FirSession) : FirScope() {
|
||||
|
||||
private val symbolProvider = FirSymbolProvider.getInstance(session)
|
||||
|
||||
|
||||
@@ -12,23 +12,23 @@ import org.jetbrains.kotlin.fir.symbols.ConeFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.ConeVariableSymbol
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
interface FirScope {
|
||||
abstract class FirScope {
|
||||
@Deprecated(
|
||||
"obsolete",
|
||||
replaceWith = ReplaceWith("processClassifiersByNameWithAction(name, position) { if (processor()) ProcessorAction.NEXT else ProcessorAction.STOP }.next()")
|
||||
)
|
||||
fun processClassifiersByName(
|
||||
open fun processClassifiersByName(
|
||||
name: Name,
|
||||
position: FirPosition,
|
||||
processor: (ConeClassifierSymbol) -> Boolean
|
||||
): Boolean = true
|
||||
|
||||
fun processFunctionsByName(
|
||||
open fun processFunctionsByName(
|
||||
name: Name,
|
||||
processor: (ConeFunctionSymbol) -> ProcessorAction
|
||||
): ProcessorAction = NEXT
|
||||
|
||||
fun processPropertiesByName(
|
||||
open fun processPropertiesByName(
|
||||
name: Name,
|
||||
processor: (ConeVariableSymbol) -> ProcessorAction
|
||||
): ProcessorAction = NEXT
|
||||
|
||||
Reference in New Issue
Block a user