NI: Add constraints which contain constraining type without projection

^KT-32243 Fixed
^KT-35172 Fixed
This commit is contained in:
Victor Petukhov
2019-11-30 20:24:46 +03:00
committed by victor.petukhov
parent 65cc0fa463
commit 775eb67219
8 changed files with 61 additions and 14 deletions
@@ -157,7 +157,6 @@ class ConstraintIncorporator(
isSubtype: Boolean
) {
if (targetVariable in getNestedTypeVariables(newConstraint)) return
if (!containsConstrainingTypeWithoutProjection(newConstraint, otherConstraint)) return
if (trivialConstraintTypeInferenceOracle.isGeneratedConstraintTrivial(
baseConstraint, otherConstraint, newConstraint, isSubtype
)
@@ -173,15 +172,6 @@ class ConstraintIncorporator(
addNewIncorporatedConstraint(targetVariable, newConstraint, ConstraintContext(kind, derivedFrom))
}
fun Context.containsConstrainingTypeWithoutProjection(
newConstraint: KotlinTypeMarker,
otherConstraint: Constraint
): Boolean {
return getNestedArguments(newConstraint).any {
it.getType().typeConstructor() == otherConstraint.type.typeConstructor() && it.getVariance() == TypeVariance.INV
}
}
fun Context.getNestedTypeVariables(type: KotlinTypeMarker): List<TypeVariableMarker> =
getNestedArguments(type).mapNotNull { getTypeVariable(it.getType().typeConstructor()) }