[NI] Fix substitution in builder-inference for empty common system

This commit is contained in:
Mikhail Zarechenskiy
2020-02-21 03:00:51 +03:00
parent c5ffbfd33c
commit 1624327ba4
12 changed files with 101 additions and 5 deletions
@@ -40,7 +40,7 @@ interface InferenceSession {
lambda: ResolvedLambdaAtom,
initialStorage: ConstraintStorage,
diagnosticsHolder: KotlinDiagnosticsHolder
): Map<TypeConstructor, UnwrappedType>
): Map<TypeConstructor, UnwrappedType>?
fun writeOnlyStubs(callInfo: SingleCallResolutionResult): Boolean
fun callCompleted(resolvedAtom: ResolvedAtom): Boolean
@@ -159,6 +159,10 @@ class PostponedArgumentsAnalyzer(
val storageSnapshot = c.getBuilder().currentStorage()
val postponedVariables = inferenceSession.inferPostponedVariables(lambda, storageSnapshot, diagnosticHolder)
if (postponedVariables == null) {
c.getBuilder().removePostponedVariables()
return
}
for ((constructor, resultType) in postponedVariables) {
val variableWithConstraints = storageSnapshot.notFixedTypeVariables[constructor] ?: continue
@@ -34,6 +34,7 @@ interface ConstraintSystemOperation {
fun registerVariable(variable: TypeVariableMarker)
fun markPostponedVariable(variable: TypeVariableMarker)
fun unmarkPostponedVariable(variable: TypeVariableMarker)
fun removePostponedVariables()
fun addSubtypeConstraint(lowerType: KotlinTypeMarker, upperType: KotlinTypeMarker, position: ConstraintPosition)
fun addEqualityConstraint(a: KotlinTypeMarker, b: KotlinTypeMarker, position: ConstraintPosition)
@@ -103,6 +103,10 @@ class NewConstraintSystemImpl(
storage.postponedTypeVariables -= variable
}
override fun removePostponedVariables() {
storage.postponedTypeVariables.clear()
}
override fun addSubtypeConstraint(lowerType: KotlinTypeMarker, upperType: KotlinTypeMarker, position: ConstraintPosition) =
constraintInjector.addInitialSubtypeConstraint(
apply { checkState(State.BUILDING, State.COMPLETION, State.TRANSACTION) },