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:
+36
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user