NI. Fix StackOverFlow in type approximation. #KT-30021 Fixed

This commit is contained in:
Dmitriy Novozhilov
2019-03-07 16:24:53 +03:00
parent cbf1d773f7
commit 9b50d31169
@@ -206,10 +206,12 @@ class TypeApproximator {
val baseResult = when (conf.intersection) {
ALLOWED -> if (!thereIsApproximation) return null else intersectTypes(newTypes)
TO_FIRST -> if (toSuper) newTypes.first() else return type.defaultResult(toSuper = false)
// commonSupertypeCalculator should handle flexible types correctly
TO_COMMON_SUPERTYPE -> if (toSuper) NewCommonSuperTypeCalculator.commonSuperType(newTypes) else return type.defaultResult(
toSuper = false
)
// commonSupertypeCalculator should handle flexible types correctly
TO_COMMON_SUPERTYPE -> {
if (!toSuper) return type.defaultResult(toSuper = false)
val resultType = NewCommonSuperTypeCalculator.commonSuperType(newTypes)
approximateToSuperType(resultType.unwrap(), conf) ?: resultType.unwrap()
}
}
return if (type.isMarkedNullable) baseResult.makeNullableAsSpecified(true) else baseResult