[FIR] Prohibit is-checks and casts for unrelated nullable types

This decision was made after a discussion
in Slack.
This commit is contained in:
Nikolay Lunyak
2024-03-07 14:36:37 +02:00
committed by Space Team
parent a4c33ee785
commit 405852980d
3 changed files with 11 additions and 2 deletions
@@ -75,7 +75,10 @@ object FirCastOperatorsChecker : FirTypeOperatorCallChecker(MppCheckerKind.Commo
return when {
isRefinementUseless(context, l.directType.upperBoundIfFlexible(), r.directType, expression) -> useless
oneIsNotNull && shouldReportAsPerRules1(l, r, context) -> impossible
shouldReportAsPerRules1(l, r, context) -> when {
oneIsNotNull -> impossible
else -> useless
}
isCastErased(l.directType, r.directType, context) -> Applicability.CAST_ERASED
else -> Applicability.APPLICABLE
}