Details
-
Task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
4.0.0
Description
SimplifyConditionals has a simplification code where if any of the (not first) branches in CaseWhen is TrueLiteral we remove all the remaining branches including the elseValue.
case CaseWhen(branches, ) if branches.exists(._1 == TrueLiteral) => // a branch with a true condition eliminates all following branches, // these branches can be pruned away val (h, t) = branches.span(_._1 != TrueLiteral) CaseWhen( h :+ t.head, None)}}
Now, the nullability check of CaseWhen checks that
(1) either of the branches including elseValue is nullable or
(2) elseValue is None.
The above simplification makes the elseValue as None. Combined with this nullability check makes the CaseWhen switch from non-nullable to nullable.
This ticket aims to fix this issue and remain the nullability of the expression by replacing the elsevalue to the value of the TrueLiteral expression.