FIR: fix nullability computation of intersection of flexible types
Without this, currently, it(ft(J..J?), ft(J..J?) => J which should be ft(J..J?) instead.
This commit is contained in:
committed by
Dmitriy Novozhilov
parent
0cb039eea7
commit
871b5a2174
@@ -145,8 +145,13 @@ 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
|
||||
ConeNullabilityChecker.isSubtypeOfAny(context, this) -> NOT_NULL
|
||||
else -> UNKNOWN
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user