[FIR] RHS assignment during equality comparison should invalidate DFA

If the right-hand side of an equality comparison contains an assignment
to the variable used in the left-hand side, then implications about the
equality comparison within data-flow analysis cannot be applied, as the
value of the variable will be different after the comparison.

^KT-55096 Fixed
This commit is contained in:
Brian Norman
2023-11-03 09:19:11 -05:00
committed by Space Team
parent 879f0eff71
commit b309786353
5 changed files with 34 additions and 11 deletions
@@ -27,9 +27,9 @@ fun unoverriddenEquals(a: Any?) {
var b: Any?
b = c
if (b == c.also { b = a }) {
a.x // bad (b#0 is C, b#1 = a)
b.x // bad (b#0 is C, this is b#1)
if (<!USELESS_IS_CHECK!>b is C<!>) { // b#1
a.<!UNRESOLVED_REFERENCE!>x<!> // bad (b#0 is C, b#1 = a)
b.<!UNRESOLVED_REFERENCE!>x<!> // bad (b#0 is C, this is b#1)
if (b is C) { // b#1
a.x // ok (b#1 = a)
b.x // ok
}