Use of uninitialized variables in lambdas / object literals / local functions is forbidden now #KT-4475 Fixed

Local declarations CFA: variable initialization information before them is now taken into account
This commit is contained in:
Mikhail Glukhikh
2015-11-11 13:05:40 +03:00
parent 89791dc85c
commit fe13f39de9
26 changed files with 245 additions and 105 deletions
@@ -0,0 +1,60 @@
== bar ==
fun bar(f: () -> Unit) = f()
---------------------
L0:
1 <START> INIT: in: {} out: {}
v(f: () -> Unit) INIT: in: {} out: {f=D}
magic[FAKE_INITIALIZER](f: () -> Unit) -> <v0> INIT: in: {f=D} out: {f=D}
w(f|<v0>) INIT: in: {f=D} out: {f=ID} USE: in: {f=READ} out: {f=READ}
r(f) -> <v1> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {f=READ}
mark(f())
call(f(), invoke|<v1>) -> <v2>
ret(*|<v2>) L1
L1:
<END>
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {f=ID} out: {f=ID} USE: in: {} out: {}
=====================
== foo ==
fun foo() {
var v: Any
bar { v.hashCode() }
}
---------------------
L0:
1 <START> INIT: in: {} out: {} USE: in: {} out: {}
2 mark({ var v: Any bar { v.hashCode() } })
v(var v: Any) INIT: in: {} out: {v=D}
mark({ v.hashCode() }) INIT: in: {v=D} out: {v=D}
jmp?(L2)
d({ v.hashCode() }) USE: in: {v=READ} out: {v=READ}
L2 [after local declaration]:
r({ v.hashCode() }) -> <v0>
mark(bar { v.hashCode() })
call(bar { v.hashCode() }, bar|<v0>) -> <v1>
L1:
1 <END> INIT: in: {} out: {}
error:
<ERROR>
sink:
<SINK> USE: in: {} out: {}
=====================
== anonymous_0 ==
{ v.hashCode() }
---------------------
L3:
3 <START> INIT: in: {v=D} out: {v=D}
4 mark(v.hashCode())
mark(v.hashCode()) USE: in: {v=READ} out: {v=READ}
r(v) -> <v0> USE: in: {} out: {v=READ}
mark(hashCode())
call(hashCode(), hashCode|<v0>) -> <v1>
L4:
3 <END>
error:
<ERROR> INIT: in: {} out: {}
sink:
<SINK> INIT: in: {v=D} out: {v=D} USE: in: {} out: {}
=====================