Fix multiple registration of same type variable in builder inference

This commit is contained in:
Simon Ogorodnik
2021-11-19 04:19:18 +03:00
committed by Space
parent 7fa13f758f
commit 9f6a812786
2 changed files with 15 additions and 17 deletions
@@ -325,14 +325,12 @@ class BuilderInferenceSession(
shouldIntegrateAllConstraints: Boolean
) {
storage.notFixedTypeVariables.values.forEach {
if (it.typeVariable.freshTypeConstructor(commonSystem.typeSystemContext) !in commonSystem.allTypeVariables) {
commonSystem.registerVariable(it.typeVariable)
}
commonSystem.registerTypeVariableIfNotPresent(it.typeVariable)
}
for (parentSession in findAllParentBuildInferenceSessions()) {
for ((variable, stubType) in parentSession.stubsForPostponedVariables) {
commonSystem.registerVariable(variable)
commonSystem.registerTypeVariableIfNotPresent(variable)
commonSystem.addSubtypeConstraint(
variable.defaultType,
stubType,
@@ -378,7 +376,7 @@ class BuilderInferenceSession(
if (shouldIntegrateAllConstraints) {
for ((variableConstructor, type) in storage.fixedTypeVariables) {
val typeVariable = storage.allTypeVariables.getValue(variableConstructor)
commonSystem.registerVariable(typeVariable)
commonSystem.registerTypeVariableIfNotPresent(typeVariable)
commonSystem.addEqualityConstraint((typeVariable as NewTypeVariable).defaultType, type, BuilderInferencePosition)
}
}