FIR: Simplify VariableStorage::isStable
This commit is contained in:
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.fir.FirSession
|
|||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
import org.jetbrains.kotlin.fir.declarations.impl.FirDefaultPropertyAccessor
|
||||||
import org.jetbrains.kotlin.fir.declarations.modality
|
import org.jetbrains.kotlin.fir.declarations.modality
|
||||||
import org.jetbrains.kotlin.fir.dispatchReceiverClassOrNull
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||||
import org.jetbrains.kotlin.fir.references.FirThisReference
|
import org.jetbrains.kotlin.fir.references.FirThisReference
|
||||||
@@ -162,18 +161,15 @@ class VariableStorage(private val session: FirSession) {
|
|||||||
property.receiverTypeRef != null -> false
|
property.receiverTypeRef != null -> false
|
||||||
property.getter.let { it != null && it !is FirDefaultPropertyAccessor } -> false
|
property.getter.let { it != null && it !is FirDefaultPropertyAccessor } -> false
|
||||||
property.modality != Modality.FINAL -> {
|
property.modality != Modality.FINAL -> {
|
||||||
val dispatchReceiver = (originalFir as? FirQualifiedAccess)?.dispatchReceiver ?: return false
|
val dispatchReceiver = (originalFir.unwrapElement() as? FirQualifiedAccess)?.dispatchReceiver ?: return false
|
||||||
val propertyClassLookupTag = (this as FirPropertySymbol).let { it.overriddenSymbol ?: it }.dispatchReceiverClassOrNull()
|
|
||||||
val receiverType = dispatchReceiver.typeRef.coneTypeSafe<ConeClassLikeType>()?.fullyExpandedType(session) ?: return false
|
val receiverType = dispatchReceiver.typeRef.coneTypeSafe<ConeClassLikeType>()?.fullyExpandedType(session) ?: return false
|
||||||
val receiverSymbol = receiverType.fullyExpandedType(session).lookupTag.toSymbol(session) ?: return false
|
val receiverSymbol = receiverType.lookupTag.toSymbol(session) ?: return false
|
||||||
val receiverClassLookupTag = receiverSymbol.toLookupTag()
|
when (val receiverFir = receiverSymbol.fir) {
|
||||||
if (propertyClassLookupTag != receiverClassLookupTag) {
|
is org.jetbrains.kotlin.fir.declarations.FirAnonymousObject -> true
|
||||||
when (val receiverFir = receiverSymbol.fir) {
|
is org.jetbrains.kotlin.fir.declarations.FirRegularClass -> receiverFir.modality == Modality.FINAL
|
||||||
is org.jetbrains.kotlin.fir.declarations.FirAnonymousObject -> true
|
else -> throw IllegalStateException("Should not be here: $receiverFir")
|
||||||
is org.jetbrains.kotlin.fir.declarations.FirRegularClass -> receiverFir.modality == Modality.FINAL
|
}
|
||||||
else -> throw IllegalStateException("Should not be here: $receiverFir")
|
|
||||||
}
|
|
||||||
} else false
|
|
||||||
}
|
}
|
||||||
else -> true
|
else -> true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user