Remove some usages of FirBasedSymbol
This commit is contained in:
+1
-2
@@ -409,8 +409,7 @@ class KotlinDeserializedJvmSymbolsProvider(
|
||||
|
||||
|
||||
private fun findRegularClass(classId: ClassId): FirRegularClass? =
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(getClassLikeSymbolByFqName(classId) as? FirBasedSymbol<FirRegularClass>)?.fir
|
||||
getClassLikeSymbolByFqName(classId)?.fir as? FirRegularClass
|
||||
|
||||
override fun getAllCallableNamesInClass(classId: ClassId): Set<Name> =
|
||||
getClassDeclarations(classId)
|
||||
|
||||
@@ -242,7 +242,7 @@ internal fun ConeKotlinType.lexicalCastFrom(session: FirSession, value: String):
|
||||
else -> return null
|
||||
}
|
||||
val lookupTag = lookupTagBasedType.lookupTag
|
||||
val firElement = (lookupTag.toSymbol(session) as? FirBasedSymbol<*>)?.fir
|
||||
val firElement = lookupTag.toSymbol(session)?.fir
|
||||
if (firElement is FirRegularClass && firElement.classKind == ClassKind.ENUM_CLASS) {
|
||||
val name = Name.identifier(value)
|
||||
val firEnumEntry = firElement.declarations.filterIsInstance<FirEnumEntry>().find { it.name == name }
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import kotlin.contracts.ExperimentalContracts
|
||||
import kotlin.contracts.contract
|
||||
|
||||
@@ -63,15 +63,15 @@ class DataFlowVariableStorage {
|
||||
private val fir2DfiMap: MutableMap<FirElement, DataFlowVariable> = mutableMapOf()
|
||||
private var debugIndexCounter: Int = 1
|
||||
|
||||
fun getOrCreateNewRealVariable(symbol: FirBasedSymbol<*>): RealDataFlowVariable {
|
||||
fun getOrCreateNewRealVariable(symbol: AbstractFirBasedSymbol<*>): RealDataFlowVariable {
|
||||
return getOrCreateNewRealVariableImpl(symbol, false)
|
||||
}
|
||||
|
||||
fun getOrCreateNewThisRealVariable(symbol: FirBasedSymbol<*>): RealDataFlowVariable {
|
||||
fun getOrCreateNewThisRealVariable(symbol: AbstractFirBasedSymbol<*>): RealDataFlowVariable {
|
||||
return getOrCreateNewRealVariableImpl(symbol, true)
|
||||
}
|
||||
|
||||
private fun getOrCreateNewRealVariableImpl(symbol: FirBasedSymbol<*>, isThisReference: Boolean): RealDataFlowVariable {
|
||||
private fun getOrCreateNewRealVariableImpl(symbol: AbstractFirBasedSymbol<*>, isThisReference: Boolean): RealDataFlowVariable {
|
||||
val fir = symbol.fir
|
||||
get(fir)?.let { return it as RealDataFlowVariable }
|
||||
return RealDataFlowVariable(debugIndexCounter++, fir, isThisReference).also { storeVariable(it, fir) }
|
||||
@@ -82,7 +82,7 @@ class DataFlowVariableStorage {
|
||||
return SyntheticDataFlowVariable(debugIndexCounter++, fir).also { storeVariable(it, fir) }
|
||||
}
|
||||
|
||||
fun createAliasVariable(symbol: FirBasedSymbol<*>, variable: RealDataFlowVariable) {
|
||||
fun createAliasVariable(symbol: AbstractFirBasedSymbol<*>, variable: RealDataFlowVariable) {
|
||||
createAliasVariable(symbol.fir, variable)
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class DataFlowVariableStorage {
|
||||
createAliasVariable(fir, newVariable)
|
||||
}
|
||||
|
||||
fun removeRealVariable(symbol: FirBasedSymbol<*>) {
|
||||
fun removeRealVariable(symbol: AbstractFirBasedSymbol<*>) {
|
||||
removeSyntheticVariable(symbol.fir)
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class DataFlowVariableStorage {
|
||||
return fir2DfiMap[firElement]
|
||||
}
|
||||
|
||||
operator fun get(symbol: FirBasedSymbol<*>): RealDataFlowVariable? {
|
||||
operator fun get(symbol: AbstractFirBasedSymbol<*>): RealDataFlowVariable? {
|
||||
return fir2DfiMap[symbol.fir] as RealDataFlowVariable?
|
||||
}
|
||||
|
||||
|
||||
+8
-8
@@ -17,8 +17,8 @@ import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStackImpl
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.Condition.*
|
||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirBodyResolveTransformer
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.FirSymbolOwner
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||
@@ -456,7 +456,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
}
|
||||
}
|
||||
|
||||
private val FirElement.resolvedSymbol: FirBasedSymbol<*>?
|
||||
private val FirElement.resolvedSymbol: AbstractFirBasedSymbol<*>?
|
||||
get() {
|
||||
val expression = (this as? FirWhenSubjectExpression)?.whenSubject?.whenExpression?.let {
|
||||
it.subjectVariable?.symbol?.let { symbol -> return symbol }
|
||||
@@ -465,7 +465,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
return (expression as? FirResolvable)?.resolvedSymbol
|
||||
}
|
||||
|
||||
private val FirResolvable.resolvedSymbol: FirBasedSymbol<*>?
|
||||
private val FirResolvable.resolvedSymbol: AbstractFirBasedSymbol<*>?
|
||||
get() = (calleeReference as? FirResolvedCallableReference)?.resolvedSymbol
|
||||
|
||||
private fun FirFunctionCall.isBooleanNot(): Boolean {
|
||||
@@ -496,7 +496,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
logicSystem.changeVariableForConditionFlow(node.flow, initializerVariable, realVariable)
|
||||
}
|
||||
|
||||
initializer.resolvedSymbol?.let { initializerSymbol: FirBasedSymbol<*> ->
|
||||
initializer.resolvedSymbol?.let { initializerSymbol: AbstractFirBasedSymbol<*> ->
|
||||
val rhsVariable = getOrCreateRealVariable(initializerSymbol)
|
||||
variableStorage.createAliasVariable(variable.symbol, rhsVariable)
|
||||
}
|
||||
@@ -662,11 +662,11 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
if (fir is FirThisReceiverExpressionImpl) {
|
||||
return variableStorage.getOrCreateNewThisRealVariable(fir.calleeReference.boundSymbol ?: return null)
|
||||
}
|
||||
val symbol: FirBasedSymbol<*> = fir.resolvedSymbol ?: return null
|
||||
val symbol = fir.resolvedSymbol ?: return null
|
||||
return variableStorage.getOrCreateNewRealVariable(symbol)
|
||||
}
|
||||
|
||||
private fun getOrCreateRealVariable(symbol: FirBasedSymbol<*>): RealDataFlowVariable =
|
||||
private fun getOrCreateRealVariable(symbol: AbstractFirBasedSymbol<*>): RealDataFlowVariable =
|
||||
variableStorage.getOrCreateNewRealVariable(symbol).variableUnderAlias
|
||||
|
||||
private fun getOrCreateVariable(fir: FirElement): DataFlowVariable {
|
||||
@@ -681,7 +681,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
|
||||
private val FirElement.realVariable: RealDataFlowVariable?
|
||||
get() {
|
||||
val symbol: FirBasedSymbol<*> = if (this is FirThisReceiverExpressionImpl) {
|
||||
val symbol = if (this is FirThisReceiverExpressionImpl) {
|
||||
calleeReference.boundSymbol
|
||||
} else {
|
||||
resolvedSymbol
|
||||
@@ -702,7 +702,7 @@ class FirDataFlowAnalyzer(transformer: FirBodyResolveTransformer) : BodyResolveC
|
||||
}
|
||||
((call.calleeReference as? FirResolvedCallableReference)?.resolvedSymbol)?.let { symbol ->
|
||||
if (symbol is FirVariableSymbol<*> || symbol is FirPropertySymbol) {
|
||||
result += getOrCreateRealVariable(symbol as FirBasedSymbol<*>)
|
||||
result += getOrCreateRealVariable(symbol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-3
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.fir.resolve.getOrPut
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirClassDeclaredMemberScope
|
||||
import org.jetbrains.kotlin.fir.symbols.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
|
||||
@@ -290,8 +289,7 @@ class FirLibrarySymbolProviderImpl(val session: FirSession) : FirSymbolProvider(
|
||||
|
||||
|
||||
private fun findRegularClass(classId: ClassId): FirRegularClass? =
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
(getClassLikeSymbolByFqName(classId) as? FirBasedSymbol<FirRegularClass>)?.fir
|
||||
getClassLikeSymbolByFqName(classId)?.fir as? FirRegularClass
|
||||
|
||||
override fun getNestedClassesNamesInClass(classId: ClassId): Set<Name> {
|
||||
return getClassDeclarations(classId).filterIsInstance<FirRegularClass>().mapTo(mutableSetOf()) { it.name }
|
||||
|
||||
@@ -8,5 +8,5 @@ package org.jetbrains.kotlin.fir.symbols
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
|
||||
interface FirSymbolOwner<E> where E : FirDeclaration, E : FirSymbolOwner<E> {
|
||||
val symbol: FirBasedSymbol<E>
|
||||
val symbol: AbstractFirBasedSymbol<E>
|
||||
}
|
||||
Reference in New Issue
Block a user