Pass KProperty instances to property delegates

Inherit KProperty from PropertyMetadata, cache corresponding KProperty objects
instead of PropertyMetadataImpl objects, add support for properties with 2
receivers
This commit is contained in:
Alexander Udalov
2015-10-12 12:11:36 +03:00
parent 4614e74e3f
commit 3c74f48f91
14 changed files with 128 additions and 129 deletions
@@ -1,36 +0,0 @@
import java.util.HashSet
class A {
val foo: String by O
val Int.foo: String by O
fun foo42() = 42.foo
}
val foo: String by O
val Int.foo: String by O
object O {
val metadatas = HashSet<PropertyMetadata>()
fun getValue(t: Any?, p: PropertyMetadata): String {
metadatas.add(p)
return ""
}
}
fun box(): String {
A().foo
A().foo42()
foo
42.foo
if (O.metadatas.size != 1)
return "Too many different PropertyMetadata instances: ${O.metadatas}"
val m = O.metadatas.iterator().next()
if (m.toString() != "PropertyMetadata(name=foo)")
return "Wrong toString(): $m"
return "OK"
}