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:
+3
-3
@@ -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<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user