527daced46
Parameters/vals with an immediate initializer (which we assume is a rather common situation) do not require any kind of complicated CFA - Unused vals can be simply determined by linear traversal of the pseudocode - Definite assignment is a bit more complicated: a read-instruction of val can be considered as a safe if it's located *after* the first write in the pseudocode. It works almost always beside the case with do/while (see the test changed). This case will be fixed in the further commits The test for kt897.kt will also be fixed further, all other changes might be considered as minor as they mostly change diagnostics for already red code
16 lines
423 B
Kotlin
Vendored
16 lines
423 B
Kotlin
Vendored
// KT-2667 Support multi-declarations in for-loops in control flow analysis
|
|
package d
|
|
|
|
class A {
|
|
operator fun component1() = 1
|
|
operator fun component2() = 2
|
|
operator fun component3() = 3
|
|
}
|
|
|
|
fun foo(list: List<A>) {
|
|
for (<!VAL_OR_VAR_ON_LOOP_PARAMETER!>var<!> (<!UNUSED_VARIABLE!>c1<!>, <!UNUSED_VARIABLE!>c2<!>, c3) in list) {
|
|
<!UNUSED_VALUE!><!VAL_REASSIGNMENT!>c1<!> =<!> 1
|
|
c3 + 1
|
|
}
|
|
}
|