[NI] Extract common parts from KotlinConstraintSystemCompleter
This commit is contained in:
+3
-3
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
import org.jetbrains.kotlin.fir.types.ConeIntegerLiteralType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.Context
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TrivialConstraintTypeInferenceOracle
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.Constraint
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||
@@ -40,7 +40,7 @@ fun Candidate.computeCompletionMode(
|
||||
}
|
||||
}
|
||||
|
||||
private typealias CsCompleterContext = Context
|
||||
private typealias CsCompleterContext = ConstraintSystemCompletionContext
|
||||
|
||||
private class CalculatorForNestedCall(
|
||||
private val candidate: Candidate,
|
||||
|
||||
+8
-11
@@ -13,10 +13,7 @@ import org.jetbrains.kotlin.fir.returnExpressions
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.TypeVariableDirectionCalculator
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.VariableFixationFinder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.NewConstraintSystemImpl
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||
@@ -31,7 +28,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
val variableFixationFinder = VariableFixationFinder(components.inferenceComponents.trivialConstraintTypeInferenceOracle)
|
||||
|
||||
fun complete(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
completionMode: ConstraintSystemCompletionMode,
|
||||
topLevelAtoms: List<FirStatement>,
|
||||
candidateReturnType: ConeKotlinType,
|
||||
@@ -77,7 +74,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
}
|
||||
|
||||
private fun resolveLambdaOrCallableReferenceWithTypeVariableAsExpectedType(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
variableForFixation: VariableFixationFinder.VariableForFixation,
|
||||
postponedAtoms: List<PostponedResolvedAtom>,
|
||||
/*diagnosticsHolder: KotlinDiagnosticsHolder,*/
|
||||
@@ -122,7 +119,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
}
|
||||
|
||||
private inline fun <T : PostponedResolvedAtom, V : ConeTypeVariable> T.preparePostponedAtomWithTypeVariableAsExpectedType(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
csBuilder: ConstraintSystemBuilder,
|
||||
variable: ConeTypeVariable,
|
||||
parameterTypes: Array<out ConeKotlinType?>?,
|
||||
@@ -161,7 +158,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
|
||||
|
||||
private fun getOrderedAllTypeVariables(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
topLevelAtoms: List<FirStatement>,
|
||||
collectVariablesFromContext: Boolean
|
||||
): List<TypeConstructorMarker> {
|
||||
@@ -199,7 +196,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
}
|
||||
|
||||
private fun fixVariable(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
topLevelType: KotlinTypeMarker,
|
||||
variableWithConstraints: VariableWithConstraints,
|
||||
postponedResolveKtPrimitives: List<PostponedResolvedAtom>
|
||||
@@ -210,7 +207,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
}
|
||||
|
||||
private fun analyzePostponeArgumentIfPossible(
|
||||
c: KotlinConstraintSystemCompleter.Context,
|
||||
c: ConstraintSystemCompletionContext,
|
||||
topLevelAtoms: List<FirStatement>,
|
||||
analyze: (PostponedResolvedAtom) -> Unit
|
||||
): Boolean {
|
||||
@@ -240,7 +237,7 @@ class ConstraintSystemCompleter(private val components: BodyResolveComponents) {
|
||||
return notAnalyzedArguments
|
||||
}
|
||||
|
||||
private fun canWeAnalyzeIt(c: KotlinConstraintSystemCompleter.Context, argument: PostponedResolvedAtomMarker): Boolean {
|
||||
private fun canWeAnalyzeIt(c: ConstraintSystemCompletionContext, argument: PostponedResolvedAtomMarker): Boolean {
|
||||
if (argument.analyzed) return false
|
||||
return argument.inputTypes.all { c.containsOnlyFixedOrPostponedVariables(it) }
|
||||
}
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.fir.types.ConeTypeVariable
|
||||
import org.jetbrains.kotlin.fir.types.ConeTypeVariableTypeConstructor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintKind
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
||||
@@ -94,7 +94,7 @@ class FirBuilderInferenceSession(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
components.callCompleter.completer.complete(
|
||||
context,
|
||||
KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL,
|
||||
ConstraintSystemCompletionMode.FULL,
|
||||
partiallyResolvedCalls.map { it.first as FirStatement },
|
||||
components.session.builtinTypes.unitType.type,
|
||||
collectVariablesFromContext = true
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.visitors.transformSingle
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||
import org.jetbrains.kotlin.types.TypeApproximatorConfiguration
|
||||
import org.jetbrains.kotlin.types.model.StubTypeMarker
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.NewConstraintSystem
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.buildAbstractResultingSubstitutor
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.ConstraintSystemCompletionMode
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.KotlinConstraintSystemCompleter
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintStorage
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||
@@ -69,7 +70,7 @@ class FirDelegatedPropertyInferenceSession(
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
components.callCompleter.completer.complete(
|
||||
commonSystem.asConstraintSystemCompleterContext(),
|
||||
KotlinConstraintSystemCompleter.ConstraintSystemCompletionMode.FULL,
|
||||
ConstraintSystemCompletionMode.FULL,
|
||||
resolvedCalls as List<FirStatement>,
|
||||
unitType
|
||||
) {
|
||||
@@ -137,4 +138,4 @@ class FirDelegatedPropertyInferenceSession(
|
||||
}
|
||||
|
||||
override fun <T> writeOnlyStubs(call: T): Boolean where T : FirResolvable, T : FirStatement = false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user