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