Delegated Properties: Analysis adjustments for local delegated properties support

This commit is contained in:
Dotlin
2016-02-07 17:43:15 +03:00
committed by Mikhael Bogdanov
parent 9bfb226948
commit fa523b9af4
32 changed files with 423 additions and 88 deletions
@@ -0,0 +1,60 @@
== Delegate ==
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
}
---------------------
L0:
1 <START>
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== getValue ==
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
---------------------
L0:
1 <START>
v(t: Any?)
magic[FAKE_INITIALIZER](t: Any?) -> <v0>
w(t|<v0>)
v(p: KProperty<*>)
magic[FAKE_INITIALIZER](p: KProperty<*>) -> <v1>
w(p|<v1>)
r(1) -> <v2>
ret(*|<v2>) L1
L1:
<END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
== foo ==
fun foo(): Int {
val prop: Int by Delegate()
return prop
}
---------------------
L0:
1 <START>
2 mark({ val prop: Int by Delegate() return prop })
v(val prop: Int by Delegate())
magic[UNRECOGNIZED_WRITE_RHS](val prop: Int by Delegate()) -> <v0>
w(prop|<v0>)
mark(Delegate())
call(Delegate(), <init>) -> <v1>
magic[FAKE_INITIALIZER](val prop: Int by Delegate()) -> <v2>
w(prop|<v2>)
magic[VALUE_CONSUMER](val prop: Int by Delegate()|<v1>) -> <v3>
r(prop) -> <v4>
ret(*|<v4>) L1
L1:
1 <END> NEXT:[<SINK>]
error:
<ERROR> PREV:[]
sink:
<SINK> PREV:[<ERROR>, <END>]
=====================
@@ -0,0 +1,10 @@
import kotlin.reflect.KProperty
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
}
fun foo(): Int {
val prop: Int by Delegate()
return prop
}
@@ -0,0 +1,27 @@
== Delegate ==
class Delegate {
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
}
---------------------
=====================
== getValue ==
operator fun getValue(t: Any?, p: KProperty<*>): Int = 1
---------------------
<v0>: * NEW: magic[FAKE_INITIALIZER](t: Any?) -> <v0>
<v1>: {<: KProperty<*>} NEW: magic[FAKE_INITIALIZER](p: KProperty<*>) -> <v1>
1 <v2>: Int NEW: r(1) -> <v2>
=====================
== foo ==
fun foo(): Int {
val prop: Int by Delegate()
return prop
}
---------------------
<v0>: Int NEW: magic[UNRECOGNIZED_WRITE_RHS](val prop: Int by Delegate()) -> <v0>
<v2>: Int NEW: magic[FAKE_INITIALIZER](val prop: Int by Delegate()) -> <v2>
<v3>: * NEW: magic[VALUE_CONSUMER](val prop: Int by Delegate()|<v1>) -> <v3>
Delegate() <v1>: * NEW: call(Delegate(), <init>) -> <v1>
prop <v4>: Int NEW: r(prop) -> <v4>
return prop !<v5>: *
{ val prop: Int by Delegate() return prop } !<v5>: * COPY
=====================