FIR DFA: don't assume != true/false => == false/true

This also fixes some returnsNotNull contracts because the old code added
an implication that `== true` => `!= null` then promptly removed any
statement that this could've affected if the argument was a synthetic
variable.

^KT-26612 tag fixed-in-k2
This commit is contained in:
pyos
2022-11-10 17:42:08 +01:00
committed by teamcity
parent 98f52f13ef
commit 5b08c300f4
9 changed files with 47 additions and 106 deletions
@@ -28,7 +28,7 @@ fun equalsFalse(x: Any?) {
x.<!UNRESOLVED_REFERENCE!>length<!>
}
else {
x.length
x.<!UNRESOLVED_REFERENCE!>length<!>
}
}
@@ -52,7 +52,7 @@ fun notEqualsTrue(x: Any?) {
fun notEqualsFalse(x: Any?) {
if (safeIsString(x) != false) {
x.length
x.<!UNRESOLVED_REFERENCE!>length<!>
}
else {
x.<!UNRESOLVED_REFERENCE!>length<!>
@@ -66,4 +66,4 @@ fun notEqualsNull(x: Any?) {
else {
x.<!UNRESOLVED_REFERENCE!>length<!>
}
}
}
@@ -14,7 +14,7 @@ fun safeIsString(x: Any?): Boolean? {
fun elseWithNullableResult(x: Any?) {
when (safeIsString(x)) {
false -> x.<!UNRESOLVED_REFERENCE!>length<!>
else -> x.length
else -> x.<!UNRESOLVED_REFERENCE!>length<!>
}
when (safeIsString(x)) {
@@ -45,12 +45,12 @@ fun exhaustiveWithNullableResult(x: Any?) {
when (safeIsString(x)) {
false -> x.<!UNRESOLVED_REFERENCE!>length<!>
true -> x.length
null -> x.length
null -> x.<!UNRESOLVED_REFERENCE!>length<!>
}
when (safeIsString(x)) {
false -> x.<!UNRESOLVED_REFERENCE!>length<!>
null -> x.length
null -> x.<!UNRESOLVED_REFERENCE!>length<!>
true -> x.length
}
}
}