From 1bb655034bbe76cbe756ddac66830eee68b485f6 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Mon, 17 Jan 2022 15:39:10 +0300 Subject: [PATCH] Inference. Add parent builder inference constraints only once --- .../inference/BuilderInferenceSession.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt index 72f7d473908..c8f8ab54138 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/BuilderInferenceSession.kt @@ -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) {