Make PropertyMetadataImpl a data class

To allow property delegates to use property metadata as a key in the hash map,
and to improve debugging experience
This commit is contained in:
Alexander Udalov
2015-08-07 16:00:22 +03:00
parent ea292fa6d2
commit 9095fa2844
4 changed files with 48 additions and 2 deletions
@@ -0,0 +1,36 @@
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 get(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"
}