[NI] Fix variable to proper upper type even if direction is TO_SUBTYPE.

This commit is contained in:
Stanislav Erokhin
2017-05-24 14:55:43 +03:00
committed by Mikhail Zarechenskiy
parent b3be21146c
commit 7eabdeffb3
@@ -65,8 +65,6 @@ class ResultTypeResolver(
}
}
if (direction == ResolveDirection.TO_SUBTYPE) return builtIns.nothingType
// direction == TO_SUPER or there is no LOWER bounds
val upperConstraints = variableWithConstraints.constraints.filter { it.kind == ConstraintKind.UPPER && c.isProperType(it.type) }
if (upperConstraints.isNotEmpty()) {
@@ -75,7 +73,13 @@ class ResultTypeResolver(
return typeApproximator.approximateToSubType(upperType, TypeApproximatorConfiguration.CapturedTypesApproximation) ?: upperType
}
return builtIns.anyType
// no proper constraints
if (direction == ResolveDirection.TO_SUBTYPE) {
return builtIns.nothingType
}
else {
return builtIns.anyType
}
}
fun findResultIfThereIsEqualsConstraint(