[FIR] Collect local properties for CFG analysis with a FIR visitor

When collecting local properties for property initialization analysis,
the nodes of the CFG were navigated. However, there are problems when
trying to determine what local properties are defined within do-while
loops. This is because the node order of a CFG does not always follow
the FIR structure order.

By converting the collector to a FIR visitor, we can maintain the
structural order needed for finding properties defined within do-while
loops. This does require some additional logic though to make sure we
do not navigate into elements which are not part of the original graph
navigation.

^KT-65911 Fixed
This commit is contained in:
Brian Norman
2024-02-27 14:11:42 -06:00
committed by Space Team
parent e16714fcf9
commit 75c6d06077
2 changed files with 77 additions and 31 deletions
@@ -1,5 +1,6 @@
// FIR_IDENTICAL
// SKIP_TXT
// ISSUE: KT-64872, KT-65911
fun test1(cond1: Boolean) {
do {
@@ -24,7 +25,6 @@ fun test2(cond1: Boolean, cond3: Boolean) {
)
}
fun test3(cond1: Boolean, cond3: Boolean) {
do {
if (cond1) continue
@@ -40,3 +40,20 @@ fun test3(cond1: Boolean, cond3: Boolean) {
}
)
}
fun test4() {
try {
for (i in 0..100) {
var counter = 0
do {
try {
} finally {
counter++
}
} while (counter < 500)
}
} catch (e: Exception) {
e.cause?.let {}
e.let {}
}
}