Inference. Add parent builder inference constraints only once

This commit is contained in:
Simon Ogorodnik
2022-01-17 15:39:10 +03:00
committed by Space
parent 9f6a812786
commit 1bb655034b
@@ -328,17 +328,6 @@ class BuilderInferenceSession(
commonSystem.registerTypeVariableIfNotPresent(it.typeVariable)
}
for (parentSession in findAllParentBuildInferenceSessions()) {
for ((variable, stubType) in parentSession.stubsForPostponedVariables) {
commonSystem.registerTypeVariableIfNotPresent(variable)
commonSystem.addSubtypeConstraint(
variable.defaultType,
stubType,
InjectedAnotherStubTypeConstraintPositionImpl(lambdaArgument)
)
}
}
/*
* storage can contain the following substitutions:
* TypeVariable(A) -> ProperType
@@ -435,6 +424,17 @@ class BuilderInferenceSession(
private fun initializeCommonSystem(initialStorage: ConstraintStorage): Boolean {
val nonFixedToVariablesSubstitutor = createNonFixedTypeToVariableSubstitutor()
for (parentSession in findAllParentBuildInferenceSessions()) {
for ((variable, stubType) in parentSession.stubsForPostponedVariables) {
commonSystem.registerTypeVariableIfNotPresent(variable)
commonSystem.addSubtypeConstraint(
variable.defaultType,
stubType,
InjectedAnotherStubTypeConstraintPositionImpl(lambdaArgument)
)
}
}
integrateConstraints(initialStorage, nonFixedToVariablesSubstitutor, false)
for (call in commonCalls) {