More precise value reassignment analysis. #KT-7418 Fixed. #KT-6902 Fixed.
Variable can now be "exactly initialized", "may be initialized" and "not initialized". A set of relevant tests. Some fixed tests.
This commit is contained in:
@@ -10,7 +10,7 @@ fun foo() {
|
||||
}
|
||||
---------------------
|
||||
L0:
|
||||
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
|
||||
2 mark({ val b: Boolean if (1 < 2) { use(b) } else { b = true } })
|
||||
v(val b: Boolean) INIT: in: {} out: {b=D}
|
||||
mark(if (1 < 2) { use(b) } else { b = true }) INIT: in: {b=D} out: {b=D}
|
||||
@@ -19,23 +19,23 @@ L0:
|
||||
mark(1 < 2)
|
||||
call(1 < 2, compareTo|<v0>, <v1>) -> <v2>
|
||||
jf(L2|<v2>)
|
||||
3 mark({ use(b) }) USE: in: {b=READ} out: {b=READ}
|
||||
r(b) -> <v3> USE: in: {} out: {b=READ}
|
||||
3 mark({ use(b) }) USE: in: {b=READ} out: {b=READ}
|
||||
r(b) -> <v3> USE: in: {} out: {b=READ}
|
||||
mark(use(b))
|
||||
call(use(b), use|<v3>) -> <v4>
|
||||
2 jmp(L3) USE: in: {} out: {}
|
||||
2 jmp(L3) USE: in: {} out: {}
|
||||
L2 [else branch]:
|
||||
3 mark({ b = true })
|
||||
r(true) -> <v5> USE: in: {b=ONLY_WRITTEN_NEVER_READ} out: {b=ONLY_WRITTEN_NEVER_READ}
|
||||
w(b|<v5>) INIT: in: {b=D} out: {b=ID} USE: in: {} out: {b=ONLY_WRITTEN_NEVER_READ}
|
||||
r(true) -> <v5> USE: in: {b=ONLY_WRITTEN_NEVER_READ} out: {b=ONLY_WRITTEN_NEVER_READ}
|
||||
w(b|<v5>) INIT: in: {b=D} out: {b=ID} USE: in: {} out: {b=ONLY_WRITTEN_NEVER_READ}
|
||||
L3 ['if' expression result]:
|
||||
2 merge(if (1 < 2) { use(b) } else { b = true }|<v4>, !<v6>) -> <v7> INIT: in: {b=D} out: {b=D}
|
||||
2 merge(if (1 < 2) { use(b) } else { b = true }|<v4>, !<v6>) -> <v7> INIT: in: {b=I?D} out: {b=I?D}
|
||||
L1:
|
||||
1 <END> INIT: in: {} out: {}
|
||||
error:
|
||||
<ERROR>
|
||||
sink:
|
||||
<SINK> USE: in: {} out: {}
|
||||
<SINK> USE: in: {} out: {}
|
||||
=====================
|
||||
== use ==
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
Reference in New Issue
Block a user