diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DataFlowInferenceContext.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DataFlowInferenceContext.kt index 680a1a586aa..1c318e2152f 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DataFlowInferenceContext.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DataFlowInferenceContext.kt @@ -11,22 +11,20 @@ import org.jetbrains.kotlin.fir.types.ConeTypeIntersector import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext -interface DataFlowInferenceContext : TypeSystemCommonSuperTypesContext, ConeInferenceContext { - fun commonSuperTypeOrNull(types: List): ConeKotlinType? { - return when (types.size) { - 0 -> null - 1 -> types.first() - else -> with(NewCommonSuperTypeCalculator) { - commonSuperType(types) as ConeKotlinType - } +fun ConeInferenceContext.commonSuperTypeOrNull(types: List): ConeKotlinType? { + return when (types.size) { + 0 -> null + 1 -> types.first() + else -> with(NewCommonSuperTypeCalculator) { + commonSuperType(types) as ConeKotlinType } } +} - fun intersectTypesOrNull(types: List): ConeKotlinType? { - return when (types.size) { - 0 -> null - 1 -> types.first() - else -> ConeTypeIntersector.intersectTypes(this as ConeInferenceContext, types) - } +fun ConeInferenceContext.intersectTypesOrNull(types: List): ConeKotlinType? { + return when (types.size) { + 0 -> null + 1 -> types.first() + else -> ConeTypeIntersector.intersectTypes(this, types) } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DelegatingLogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DelegatingLogicSystem.kt index 8cbd06e0d70..e05b1cf56f1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DelegatingLogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/DelegatingLogicSystem.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa import com.google.common.collect.ArrayListMultimap import com.google.common.collect.Multimap +import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext class DelegatingFlow( val previousFlow: DelegatingFlow?, @@ -122,7 +123,7 @@ private class ImmutableMultimap(private val original: Multimap) : Mu } } -abstract class DelegatingLogicSystem(context: DataFlowInferenceContext) : LogicSystem(context) { +abstract class DelegatingLogicSystem(context: ConeInferenceContext) : LogicSystem(context) { override val Flow.approvedInfos: MutableApprovedInfos get() = (this as DelegatingFlow).approvedInfos @@ -228,4 +229,4 @@ abstract class DelegatingLogicSystem(context: DataFlowInferenceContext) : LogicS } return approvedInfos } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt index ab07a1ab8c6..f46cb303ab3 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/FirDataFlowAnalyzer.kt @@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStackImpl import org.jetbrains.kotlin.fir.resolve.ResolutionMode +import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate import org.jetbrains.kotlin.fir.resolve.dfa.Condition.* import org.jetbrains.kotlin.fir.resolve.dfa.cfg.* @@ -45,7 +46,7 @@ class FirDataFlowAnalyzer(private val components: FirAbstractBodyResolveTransfor private val KOTLIN_BOOLEAN_NOT = CallableId(FqName("kotlin"), FqName("Boolean"), Name.identifier("not")) } - private val context: DataFlowInferenceContext get() = inferenceComponents.ctx as DataFlowInferenceContext + private val context: ConeInferenceContext get() = inferenceComponents.ctx private val receiverStack: ImplicitReceiverStackImpl = components.implicitReceiverStack as ImplicitReceiverStackImpl private val graphBuilder = ControlFlowGraphBuilder() @@ -898,7 +899,7 @@ class FirDataFlowAnalyzer(private val components: FirAbstractBodyResolveTransfor return result } - private inner class LogicSystemImpl(context: DataFlowInferenceContext) : DelegatingLogicSystem(context) { + private inner class LogicSystemImpl(context: ConeInferenceContext) : DelegatingLogicSystem(context) { override fun processUpdatedReceiverVariable(flow: Flow, variable: RealDataFlowVariable) { val symbol = (variable.fir as? FirSymbolOwner<*>)?.symbol ?: return diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt index edfe84a6e83..a9ba333d3f1 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/LogicSystem.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa import com.google.common.collect.ArrayListMultimap +import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext import org.jetbrains.kotlin.fir.types.ConeKotlinType interface Flow { @@ -17,7 +18,7 @@ interface Flow { fun removeConditionalInfos(variable: DataFlowVariable): Collection } -abstract class LogicSystem(private val context: DataFlowInferenceContext) { +abstract class LogicSystem(private val context: ConeInferenceContext) { // ------------------------------- Flow operations ------------------------------- @@ -193,4 +194,4 @@ abstract class LogicSystem(private val context: DataFlowInferenceContext) { context.commonSuperTypeOrNull(differentTypes.toList())?.let { commonTypes += it } return commonTypes } -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/SimpleLogicSystem.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/SimpleLogicSystem.kt index a22cee24eb2..65f1551f462 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/SimpleLogicSystem.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/dfa/SimpleLogicSystem.kt @@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa import com.google.common.collect.ArrayListMultimap import com.google.common.collect.HashMultimap import com.google.common.collect.Multimap +import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext private class SimpleFlow( val approvedInfos: MutableApprovedInfos = mutableMapOf(), @@ -30,7 +31,7 @@ private class SimpleFlow( } } -abstract class SimpleLogicSystem(context: DataFlowInferenceContext) : LogicSystem(context) { +abstract class SimpleLogicSystem(context: ConeInferenceContext) : LogicSystem(context) { override val Flow.approvedInfos: MutableApprovedInfos get() = (this as SimpleFlow).approvedInfos @@ -102,4 +103,4 @@ abstract class SimpleLogicSystem(context: DataFlowInferenceContext) : LogicSyste } } -private fun Multimap.copy(): Multimap = ArrayListMultimap.create(this) \ No newline at end of file +private fun Multimap.copy(): Multimap = ArrayListMultimap.create(this) diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt index 987cca611bd..926f0e5b043 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/BodyResolveUtils.kt @@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.renderWithType import org.jetbrains.kotlin.fir.resolve.ScopeSession import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext import org.jetbrains.kotlin.fir.resolve.calls.InferenceComponents -import org.jetbrains.kotlin.fir.resolve.dfa.DataFlowInferenceContext import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.types.FirTypeRef @@ -33,7 +32,7 @@ internal inline var FirExpression.resultType: FirTypeRef } interface UniversalConeInferenceContext : - ConeInferenceContext, TypeSystemInferenceExtensionContextDelegate, DataFlowInferenceContext + ConeInferenceContext, TypeSystemInferenceExtensionContextDelegate internal fun FirSession.inferenceContext(): UniversalConeInferenceContext { val session = this @@ -50,4 +49,4 @@ internal fun inferenceComponents( ): InferenceComponents { val inferenceContext = session.inferenceContext() return InferenceComponents(inferenceContext, session, returnTypeCalculator, scopeSession) -} \ No newline at end of file +} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt index ac631c9d399..a15eb4a46b0 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/transformers/body/resolve/FirDeclarationsResolveTransformer.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.resolve.* import org.jetbrains.kotlin.fir.resolve.calls.ImplicitDispatchReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue import org.jetbrains.kotlin.fir.resolve.calls.extractLambdaInfoFromFunctionalType +import org.jetbrains.kotlin.fir.resolve.dfa.commonSuperTypeOrNull import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor import org.jetbrains.kotlin.fir.resolve.transformers.* import org.jetbrains.kotlin.fir.resolve.transformers.FirStatusResolveTransformer.Companion.resolveStatus