[NI] Prioritize variables with trivial constraints over complex ones

Consider the following constraint system (from the test example):

Nothing? <: V1
F!! <: V2
Inv<V1> <: S
Inv<V2> <: S

Where V1, V2, S are type variables, and F has nullable upper bound.
Type variable fixation order should be: V2 -> V1 -> S, and the problem
was that previously after fixation of type variable V2 we were trying
to fix S (before V1), so we had the following constraints on S:
Inv<F!!> <: S
Inv<V1> <: S
=> S were fixed to Inv<F!!>

And after this V1 was fixed to F!! which is contradictory as Nothing?
is not a subtype of F!!.

 #KT-33033 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-11-01 15:50:48 +03:00
parent 5582fd4056
commit 650e2501bb
6 changed files with 51 additions and 2 deletions
@@ -10334,6 +10334,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/inference/constraints/errorUpperBoundConstraint.kt");
}
@TestMetadata("fixTypeVariableWithNothingConstraintEarlierThanComplexVariable.kt")
public void testFixTypeVariableWithNothingConstraintEarlierThanComplexVariable() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/fixTypeVariableWithNothingConstraintEarlierThanComplexVariable.kt");
}
@TestMetadata("ignoreConstraintFromImplicitInNothing.kt")
public void testIgnoreConstraintFromImplicitInNothing() throws Exception {
runTest("compiler/testData/diagnostics/tests/inference/constraints/ignoreConstraintFromImplicitInNothing.kt");