Minor. Get rid of DataFlowInferenceContext
This commit is contained in:
+14
-16
@@ -11,22 +11,20 @@ import org.jetbrains.kotlin.fir.types.ConeTypeIntersector
|
|||||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator
|
||||||
import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext
|
import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext
|
||||||
|
|
||||||
interface DataFlowInferenceContext : TypeSystemCommonSuperTypesContext, ConeInferenceContext {
|
fun ConeInferenceContext.commonSuperTypeOrNull(types: List<ConeKotlinType>): ConeKotlinType? {
|
||||||
fun commonSuperTypeOrNull(types: List<ConeKotlinType>): ConeKotlinType? {
|
return when (types.size) {
|
||||||
return when (types.size) {
|
0 -> null
|
||||||
0 -> null
|
1 -> types.first()
|
||||||
1 -> types.first()
|
else -> with(NewCommonSuperTypeCalculator) {
|
||||||
else -> with(NewCommonSuperTypeCalculator) {
|
commonSuperType(types) as ConeKotlinType
|
||||||
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+2
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa
|
|||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
import com.google.common.collect.Multimap
|
import com.google.common.collect.Multimap
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||||
|
|
||||||
class DelegatingFlow(
|
class DelegatingFlow(
|
||||||
val previousFlow: 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
|
override val Flow.approvedInfos: MutableApprovedInfos
|
||||||
get() = (this as DelegatingFlow).approvedInfos
|
get() = (this as DelegatingFlow).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.BodyResolveComponents
|
||||||
import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStackImpl
|
import org.jetbrains.kotlin.fir.resolve.ImplicitReceiverStackImpl
|
||||||
import org.jetbrains.kotlin.fir.resolve.ResolutionMode
|
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.calls.FirNamedReferenceWithCandidate
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.Condition.*
|
import org.jetbrains.kotlin.fir.resolve.dfa.Condition.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.dfa.cfg.*
|
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 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 receiverStack: ImplicitReceiverStackImpl = components.implicitReceiverStack as ImplicitReceiverStackImpl
|
||||||
|
|
||||||
private val graphBuilder = ControlFlowGraphBuilder()
|
private val graphBuilder = ControlFlowGraphBuilder()
|
||||||
@@ -898,7 +899,7 @@ class FirDataFlowAnalyzer(private val components: FirAbstractBodyResolveTransfor
|
|||||||
return result
|
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) {
|
override fun processUpdatedReceiverVariable(flow: Flow, variable: RealDataFlowVariable) {
|
||||||
val symbol = (variable.fir as? FirSymbolOwner<*>)?.symbol ?: return
|
val symbol = (variable.fir as? FirSymbolOwner<*>)?.symbol ?: return
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve.dfa
|
package org.jetbrains.kotlin.fir.resolve.dfa
|
||||||
|
|
||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||||
|
|
||||||
interface Flow {
|
interface Flow {
|
||||||
@@ -17,7 +18,7 @@ interface Flow {
|
|||||||
fun removeConditionalInfos(variable: DataFlowVariable): Collection<ConditionalFirDataFlowInfo>
|
fun removeConditionalInfos(variable: DataFlowVariable): Collection<ConditionalFirDataFlowInfo>
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class LogicSystem(private val context: DataFlowInferenceContext) {
|
abstract class LogicSystem(private val context: ConeInferenceContext) {
|
||||||
|
|
||||||
// ------------------------------- Flow operations -------------------------------
|
// ------------------------------- Flow operations -------------------------------
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.dfa
|
|||||||
import com.google.common.collect.ArrayListMultimap
|
import com.google.common.collect.ArrayListMultimap
|
||||||
import com.google.common.collect.HashMultimap
|
import com.google.common.collect.HashMultimap
|
||||||
import com.google.common.collect.Multimap
|
import com.google.common.collect.Multimap
|
||||||
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||||
|
|
||||||
private class SimpleFlow(
|
private class SimpleFlow(
|
||||||
val approvedInfos: MutableApprovedInfos = mutableMapOf(),
|
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
|
override val Flow.approvedInfos: MutableApprovedInfos
|
||||||
get() = (this as SimpleFlow).approvedInfos
|
get() = (this as SimpleFlow).approvedInfos
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -12,7 +12,6 @@ import org.jetbrains.kotlin.fir.renderWithType
|
|||||||
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
import org.jetbrains.kotlin.fir.resolve.ScopeSession
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
import org.jetbrains.kotlin.fir.resolve.calls.ConeInferenceContext
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.InferenceComponents
|
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.resolve.transformers.ReturnTypeCalculator
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
@@ -33,7 +32,7 @@ internal inline var FirExpression.resultType: FirTypeRef
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface UniversalConeInferenceContext :
|
interface UniversalConeInferenceContext :
|
||||||
ConeInferenceContext, TypeSystemInferenceExtensionContextDelegate, DataFlowInferenceContext
|
ConeInferenceContext, TypeSystemInferenceExtensionContextDelegate
|
||||||
|
|
||||||
internal fun FirSession.inferenceContext(): UniversalConeInferenceContext {
|
internal fun FirSession.inferenceContext(): UniversalConeInferenceContext {
|
||||||
val session = this
|
val session = this
|
||||||
|
|||||||
+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.ImplicitDispatchReceiverValue
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue
|
import org.jetbrains.kotlin.fir.resolve.calls.ImplicitExtensionReceiverValue
|
||||||
import org.jetbrains.kotlin.fir.resolve.calls.extractLambdaInfoFromFunctionalType
|
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.substitution.ConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.*
|
import org.jetbrains.kotlin.fir.resolve.transformers.*
|
||||||
import org.jetbrains.kotlin.fir.resolve.transformers.FirStatusResolveTransformer.Companion.resolveStatus
|
import org.jetbrains.kotlin.fir.resolve.transformers.FirStatusResolveTransformer.Companion.resolveStatus
|
||||||
|
|||||||
Reference in New Issue
Block a user