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
@@ -66,7 +66,7 @@ fun case_2(value_1: Int?, value_2: Int?, value_3: Any?) {
println(value_2)
}
null -> {
println(value_3?.xor(true))
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value_3?.<!UNRESOLVED_REFERENCE!>xor<!>(true))
println(<!UNINITIALIZED_VARIABLE!>value_4<!>)
println(value_1)
println(value_2)
@@ -61,7 +61,7 @@ fun case_2(value_1: Int?, value_2: Int?, value_3: Any?) {
println(value_2)
}
null -> {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value_3?.<!UNRESOLVED_REFERENCE!>xor<!>(true))
println(value_3?.xor(true))
println(value_4)
println(value_1)
println(value_2)
@@ -94,7 +94,7 @@ fun case_4(value_1: Number, value_2: (() -> Unit)?) {
} else if (contracts.case_4(value_1, value_2) == false) {
println(value_2)
} else if (contracts.case_4(value_1, value_2) == null) {
value_2()
<!UNSAFE_IMPLICIT_INVOKE_CALL!>value_2<!>()
}
}
@@ -107,7 +107,7 @@ fun case_5(value_1: Number?, value_2: String?) {
}
false -> {
println(value_2<!UNSAFE_CALL!>.<!>length)
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>inv<!>())
println(value_1.inv())
}
}
}
@@ -124,7 +124,7 @@ fun case_6(value_1: Number, value_2: String?, value_3: Any?) {
println(value_2<!UNSAFE_CALL!>.<!>length)
}
null -> {
println(value_1.inv())
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>inv<!>())
}
}
}
@@ -110,7 +110,7 @@ fun case_5(value_1: Number?, value_2: String?) {
println(value_1.toByte())
}
false -> {
println(value_2<!UNSAFE_CALL!>.<!>length)
println(value_2.length)
println(value_1.inv())
}
}
@@ -129,10 +129,10 @@ fun case_6(value_1: Number, value_2: String?, value_3: Any?) {
}
false -> {
println(value_3.length)
println(value_2<!UNSAFE_CALL!>.<!>length)
println(value_2.length)
}
null -> {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value_1.<!UNRESOLVED_REFERENCE!>inv<!>())
println(value_1.inv())
}
}
}