[NI] Get rid of ResolvedAtom usage in ConstraintSystemCompletionContext
This commit is contained in:
+2
-2
@@ -7,8 +7,8 @@ package org.jetbrains.kotlin.resolve.calls.inference.components
|
||||
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.ConstraintSystemError
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.FixVariableConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.VariableWithConstraints
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeConstructorMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
@@ -28,7 +28,7 @@ interface ConstraintSystemCompletionContext : VariableFixationFinder.Context, Re
|
||||
// mutable operations
|
||||
fun addError(error: ConstraintSystemError)
|
||||
|
||||
fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, atom: ResolvedAtom?)
|
||||
fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, position: FixVariableConstraintPosition<*>)
|
||||
|
||||
fun asConstraintSystemCompletionContext(): ConstraintSystemCompletionContext
|
||||
}
|
||||
|
||||
+4
-3
@@ -238,8 +238,9 @@ class KotlinConstraintSystemCompleter(
|
||||
topLevelAtoms: List<ResolvedAtom>
|
||||
) {
|
||||
val resultType = resultTypeResolver.findResultType(c, variableWithConstraints, direction)
|
||||
val resolvedAtom = findResolvedAtomBy(variableWithConstraints.typeVariable, topLevelAtoms) ?: topLevelAtoms.firstOrNull()
|
||||
c.fixVariable(variableWithConstraints.typeVariable, resultType, resolvedAtom)
|
||||
val variable = variableWithConstraints.typeVariable
|
||||
val resolvedAtom = findResolvedAtomBy(variable, topLevelAtoms) ?: topLevelAtoms.firstOrNull()
|
||||
c.fixVariable(variable, resultType, FixVariableConstraintPositionImpl(variable, resolvedAtom))
|
||||
}
|
||||
|
||||
private fun ConstraintSystemCompletionContext.fixVariablesOrReportNotEnoughInformation(
|
||||
@@ -300,7 +301,7 @@ class KotlinConstraintSystemCompleter(
|
||||
else -> ErrorUtils.createErrorType("Cannot infer type variable $typeVariable")
|
||||
}
|
||||
|
||||
c.fixVariable(typeVariable, resultErrorType, resolvedAtom)
|
||||
c.fixVariable(typeVariable, resultErrorType, FixVariableConstraintPositionImpl(typeVariable, resolvedAtom))
|
||||
}
|
||||
|
||||
private fun ConstraintSystemCompletionContext.getOrderedAllTypeVariables(
|
||||
|
||||
+3
-2
@@ -468,10 +468,11 @@ class PostponedArgumentInputTypesResolver(
|
||||
val variableWithConstraints = notFixedTypeVariables.getValue(variableForFixation.variable)
|
||||
val resultType =
|
||||
resultTypeResolver.findResultType(this, variableWithConstraints, TypeVariableDirectionCalculator.ResolveDirection.UNKNOWN)
|
||||
val resolvedAtom = KotlinConstraintSystemCompleter.findResolvedAtomBy(variableWithConstraints.typeVariable, topLevelAtoms)
|
||||
val variable = variableWithConstraints.typeVariable
|
||||
val resolvedAtom = KotlinConstraintSystemCompleter.findResolvedAtomBy(variable, topLevelAtoms)
|
||||
?: topLevelAtoms.firstOrNull()
|
||||
|
||||
fixVariable(variableWithConstraints.typeVariable, resultType, resolvedAtom)
|
||||
fixVariable(variable, resultType, FixVariableConstraintPositionImpl(variable, resolvedAtom))
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
+2
-3
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.resolve.calls.inference.model
|
||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.*
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.components.*
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedAtom
|
||||
import org.jetbrains.kotlin.types.*
|
||||
import org.jetbrains.kotlin.types.checker.NewKotlinTypeChecker
|
||||
import org.jetbrains.kotlin.types.model.*
|
||||
@@ -292,11 +291,11 @@ class NewConstraintSystemImpl(
|
||||
|
||||
// KotlinConstraintSystemCompleter.Context
|
||||
// TODO: simplify this: do only substitution a fixing type variable rather than running of subtyping and full incorporation
|
||||
override fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, atom: ResolvedAtom?) {
|
||||
override fun fixVariable(variable: TypeVariableMarker, resultType: KotlinTypeMarker, position: FixVariableConstraintPosition<*>) {
|
||||
checkState(State.BUILDING, State.COMPLETION)
|
||||
|
||||
constraintInjector.addInitialEqualityConstraint(
|
||||
this, variable.defaultType(), resultType, FixVariableConstraintPositionImpl(variable, atom)
|
||||
this, variable.defaultType(), resultType, position
|
||||
)
|
||||
|
||||
val freshTypeConstructor = variable.freshTypeConstructor()
|
||||
|
||||
Reference in New Issue
Block a user