FIR: fold two last getOrderedAllTypeVariables calls into one (stage 7,8)
This commit saves us some performance and fixes test for KT-35684. FIR-based constraint completer at this moment can't extract type variables from already completed calls. Folding allows us to extract ordered type variables before completion.
This commit is contained in:
committed by
teamcity
parent
7f62d1bc5a
commit
c324bbfc37
+7
-8
@@ -149,8 +149,9 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
// Stage 7: try to complete call with the builder inference if there are uninferred type variables
|
// Stage 7: try to complete call with the builder inference if there are uninferred type variables
|
||||||
|
val allTypeVariables = getOrderedAllTypeVariables(collectVariablesFromContext, topLevelAtoms)
|
||||||
val areThereAppearedProperConstraintsForSomeVariable = tryToCompleteWithBuilderInference(
|
val areThereAppearedProperConstraintsForSomeVariable = tryToCompleteWithBuilderInference(
|
||||||
completionMode, topLevelAtoms, topLevelType, postponedArguments, collectVariablesFromContext, analyze
|
completionMode, topLevelType, postponedArguments, allTypeVariables, analyze
|
||||||
)
|
)
|
||||||
|
|
||||||
if (areThereAppearedProperConstraintsForSomeVariable)
|
if (areThereAppearedProperConstraintsForSomeVariable)
|
||||||
@@ -158,7 +159,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
|
|
||||||
// Stage 8: report "not enough information" for uninferred type variables
|
// Stage 8: report "not enough information" for uninferred type variables
|
||||||
reportNotEnoughTypeInformation(
|
reportNotEnoughTypeInformation(
|
||||||
completionMode, topLevelAtoms, topLevelType, collectVariablesFromContext, postponedArguments
|
completionMode, topLevelAtoms, topLevelType, allTypeVariables, postponedArguments
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stage 9: force analysis of remaining not analyzed postponed arguments and rerun stages if there are
|
// Stage 9: force analysis of remaining not analyzed postponed arguments and rerun stages if there are
|
||||||
@@ -173,10 +174,9 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
|
|
||||||
private fun ConstraintSystemCompletionContext.tryToCompleteWithBuilderInference(
|
private fun ConstraintSystemCompletionContext.tryToCompleteWithBuilderInference(
|
||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<FirStatement>,
|
|
||||||
topLevelType: ConeKotlinType,
|
topLevelType: ConeKotlinType,
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
collectVariablesFromContext: Boolean,
|
allTypeVariables: List<TypeConstructorMarker>,
|
||||||
analyze: (PostponedResolvedAtom) -> Unit
|
analyze: (PostponedResolvedAtom) -> Unit
|
||||||
): Boolean {
|
): Boolean {
|
||||||
if (completionMode == ConstraintSystemCompletionMode.PARTIAL) return false
|
if (completionMode == ConstraintSystemCompletionMode.PARTIAL) return false
|
||||||
@@ -202,7 +202,7 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
}
|
}
|
||||||
|
|
||||||
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
||||||
this, getOrderedAllTypeVariables(collectVariablesFromContext, topLevelAtoms), postponedArguments, completionMode, topLevelType
|
this, allTypeVariables, postponedArguments, completionMode, topLevelType
|
||||||
)
|
)
|
||||||
|
|
||||||
// continue completion (rerun stages) only if ready for fixation variables with proper constraints have appeared
|
// continue completion (rerun stages) only if ready for fixation variables with proper constraints have appeared
|
||||||
@@ -267,13 +267,12 @@ class ConstraintSystemCompleter(components: BodyResolveComponents, private val c
|
|||||||
completionMode: ConstraintSystemCompletionMode,
|
completionMode: ConstraintSystemCompletionMode,
|
||||||
topLevelAtoms: List<FirStatement>,
|
topLevelAtoms: List<FirStatement>,
|
||||||
topLevelType: ConeKotlinType,
|
topLevelType: ConeKotlinType,
|
||||||
collectVariablesFromContext: Boolean,
|
allTypeVariables: List<TypeConstructorMarker>,
|
||||||
postponedArguments: List<PostponedResolvedAtom>,
|
postponedArguments: List<PostponedResolvedAtom>,
|
||||||
) {
|
) {
|
||||||
while (true) {
|
while (true) {
|
||||||
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
val variableForFixation = variableFixationFinder.findFirstVariableForFixation(
|
||||||
this, getOrderedAllTypeVariables(collectVariablesFromContext, topLevelAtoms),
|
this, allTypeVariables, postponedArguments, completionMode, topLevelType,
|
||||||
postponedArguments, completionMode, topLevelType,
|
|
||||||
) ?: break
|
) ?: break
|
||||||
|
|
||||||
assert(!variableForFixation.hasProperConstraint) {
|
assert(!variableForFixation.hasProperConstraint) {
|
||||||
|
|||||||
Reference in New Issue
Block a user