Approximate only types substituted with captured types

properly fixes #KT-37389
#KT-37389 fixed
#KT-37644 fixed
This commit is contained in:
Ilya Chernikov
2020-03-23 17:12:55 +01:00
parent 49ae3c3db0
commit 44ffed9590
@@ -126,17 +126,11 @@ class ConstraintIncorporator(
if (needApproximation) approximateCapturedTypes(typeWithSubstitution, toSuper) else typeWithSubstitution if (needApproximation) approximateCapturedTypes(typeWithSubstitution, toSuper) else typeWithSubstitution
} }
when (baseConstraint.kind) { if (baseConstraint.kind != ConstraintKind.LOWER) {
ConstraintKind.EQUALITY -> { addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, prepareType(true), isSubtype = false)
addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, typeWithSubstitution, isSubtype = false) }
addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, typeWithSubstitution, isSubtype = true) if (baseConstraint.kind != ConstraintKind.UPPER) {
} addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, prepareType(false), isSubtype = true)
ConstraintKind.UPPER -> {
addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, prepareType(true), isSubtype = false)
}
ConstraintKind.LOWER -> {
addNewConstraint(targetVariable, baseConstraint, otherVariable, otherConstraint, prepareType(false), isSubtype = true)
}
} }
} }
@@ -150,7 +144,7 @@ class ConstraintIncorporator(
val isOtherCapturedType = otherConstraint.type.isCapturedType() val isOtherCapturedType = otherConstraint.type.isCapturedType()
val (type, needApproximation) = when (otherConstraint.kind) { val (type, needApproximation) = when (otherConstraint.kind) {
ConstraintKind.EQUALITY -> { ConstraintKind.EQUALITY -> {
otherConstraint.type to true otherConstraint.type to false
} }
ConstraintKind.UPPER -> { ConstraintKind.UPPER -> {
/* /*