Minor. Get rid of DataFlowInferenceContext
This commit is contained in:
+13
-15
@@ -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>): ConeKotlinType? {
|
||||
return when (types.size) {
|
||||
0 -> null
|
||||
1 -> types.first()
|
||||
else -> with(NewCommonSuperTypeCalculator) {
|
||||
commonSuperType(types) as ConeKotlinType
|
||||
}
|
||||
fun ConeInferenceContext.commonSuperTypeOrNull(types: List<ConeKotlinType>): ConeKotlinType? {
|
||||
return when (types.size) {
|
||||
0 -> null
|
||||
1 -> types.first()
|
||||
else -> with(NewCommonSuperTypeCalculator) {
|
||||
commonSuperType(types) as ConeKotlinType
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun intersectTypesOrNull(types: List<ConeKotlinType>): ConeKotlinType? {
|
||||
return when (types.size) {
|
||||
0 -> null
|
||||
1 -> types.first()
|
||||
else -> ConeTypeIntersector.intersectTypes(this as ConeInferenceContext, types)
|
||||
}
|
||||
fun ConeInferenceContext.intersectTypesOrNull(types: List<ConeKotlinType>): ConeKotlinType? {
|
||||
return when (types.size) {
|
||||
0 -> null
|
||||
1 -> types.first()
|
||||
else -> ConeTypeIntersector.intersectTypes(this, types)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -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<K, V>(private val original: Multimap<K, V>) : 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -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
|
||||
|
||||
|
||||
@@ -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<ConditionalFirDataFlowInfo>
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <K, V> Multimap<K, V>.copy(): Multimap<K, V> = ArrayListMultimap.create(this)
|
||||
private fun <K, V> Multimap<K, V>.copy(): Multimap<K, V> = ArrayListMultimap.create(this)
|
||||
|
||||
+2
-3
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user