FIR: more accurate nullability of intersection of flexible types

This commit is contained in:
Jinseong Jeon
2021-04-01 22:58:58 -07:00
committed by Dmitriy Novozhilov
parent 871b5a2174
commit 0d3969597c
4 changed files with 21 additions and 6 deletions
@@ -145,11 +145,7 @@ object ConeTypeIntersector {
protected fun ConeKotlinType.resultNullability(context: ConeTypeContext): ResultNullability =
when {
isMarkedNullable -> ACCEPT_NULL
// Technically, upper bound's nullability is more accurate, e.g., a type from Java with @NotNull.
// However, it requires one more recursive call here. In contrast, UNKNOWN here is a safe approximation: for even such
// flexible type case, as long as the upper bound is still used in the intersection computation (and it indeed is),
// we will still get the same nullability from the resulting intersected type.
this is ConeFlexibleType -> UNKNOWN
this is ConeFlexibleType -> upperBound.resultNullability(context)
ConeNullabilityChecker.isSubtypeOfAny(context, this) -> NOT_NULL
else -> UNKNOWN
}