From b564260a336954e77996c9b8b255e6e2a44f3318 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 2 Jun 2023 11:29:24 +0300 Subject: [PATCH] [FIR] Drop ImplicitReceiverValue.expandedType This field cached expansion of type of implicit receiver, which is incorrect, because type of receiver may change because of smartcasts, but this field was immutable --- .../org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt | 4 +--- .../kotlin/fir/declarations/ImplicitReceiverUtils.kt | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt index 113c991c7d0..84f0e51609a 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/resolve/calls/FirReceivers.kt @@ -97,7 +97,7 @@ open class ExpressionReceiverValue( sealed class ImplicitReceiverValue>( val boundSymbol: S, type: ConeKotlinType, - protected val useSiteSession: FirSession, + val useSiteSession: FirSession, protected val scopeSession: ScopeSession, private val mutable: Boolean, val contextReceiverNumber: Int = -1, @@ -110,8 +110,6 @@ sealed class ImplicitReceiverValue>( val originalType: ConeKotlinType = type - val expandedType: ConeKotlinType = type.applyIf(type is ConeClassLikeType) { fullyExpandedType(useSiteSession) } - var implicitScope: FirTypeScope? = type.scope( useSiteSession, diff --git a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/declarations/ImplicitReceiverUtils.kt b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/declarations/ImplicitReceiverUtils.kt index 0f8a4f011be..732f5b17961 100644 --- a/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/declarations/ImplicitReceiverUtils.kt +++ b/compiler/fir/semantics/src/org/jetbrains/kotlin/fir/declarations/ImplicitReceiverUtils.kt @@ -276,7 +276,7 @@ class FirTowerDataElement( } private fun ImplicitReceiverValue<*>.getImplicitScope(): FirScope { - return when (expandedType) { + return when (type.fullyExpandedType(useSiteSession)) { is ConeErrorType, is ConeStubType -> FirTypeScope.Empty else -> implicitScope ?: error("Scope for type ${type::class.simpleName} is null.")