From d3ee2844610a0fc3443d32022ad0b969ab69efde Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Thu, 23 Dec 2021 18:50:57 +0300 Subject: [PATCH] [FE 1.0] Check for readiness to fix for all type variables after try analysing a lambda with the builder inference ^KT-50498 Fixed --- .../components/KotlinConstraintSystemCompleter.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt index bbc53272267..3263c80502e 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/KotlinConstraintSystemCompleter.kt @@ -143,8 +143,9 @@ class KotlinConstraintSystemCompleter( continue // Stage 7: try to complete call with the builder inference if there are uninferred type variables - val areThereAppearedProperConstraintsForSomeVariable = - tryToCompleteWithBuilderInference(completionMode, topLevelType, postponedArguments, analyze) + val areThereAppearedProperConstraintsForSomeVariable = tryToCompleteWithBuilderInference( + completionMode, topLevelAtoms, topLevelType, postponedArguments, collectVariablesFromContext, analyze + ) if (areThereAppearedProperConstraintsForSomeVariable) continue @@ -166,8 +167,10 @@ class KotlinConstraintSystemCompleter( private fun ConstraintSystemCompletionContext.tryToCompleteWithBuilderInference( completionMode: ConstraintSystemCompletionMode, + topLevelAtoms: List, topLevelType: UnwrappedType, postponedArguments: List, + collectVariablesFromContext: Boolean, analyze: (PostponedResolvedAtom) -> Unit ): Boolean { if (completionMode == ConstraintSystemCompletionMode.PARTIAL) return false @@ -180,7 +183,6 @@ class KotlinConstraintSystemCompleter( val lambdaArguments = postponedArguments.filterIsInstance().takeIf { it.isNotEmpty() } ?: return false val useBuilderInferenceWithoutAnnotation = languageVersionSettings.supportsFeature(LanguageFeature.UseBuilderInferenceWithoutAnnotation) - val allNotFixedInputTypeVariables = mutableSetOf() for (argument in lambdaArguments) { if (!argument.atom.hasBuilderInferenceAnnotation && !useBuilderInferenceWithoutAnnotation) @@ -191,8 +193,6 @@ class KotlinConstraintSystemCompleter( if (notFixedInputTypeVariables.isEmpty()) continue - allNotFixedInputTypeVariables.addAll(notFixedInputTypeVariables) - for (variable in notFixedInputTypeVariables) { getBuilder().markPostponedVariable(notFixedTypeVariables.getValue(variable).typeVariable) } @@ -201,7 +201,7 @@ class KotlinConstraintSystemCompleter( } val variableForFixation = variableFixationFinder.findFirstVariableForFixation( - this, allNotFixedInputTypeVariables.toList(), postponedArguments, completionMode, topLevelType + this, getOrderedAllTypeVariables(collectVariablesFromContext, topLevelAtoms), postponedArguments, completionMode, topLevelType ) // continue completion (rerun stages) only if ready for fixation variables with proper constraints have appeared