Introduce propertyDelegated method in delegates
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
class Delegate {
|
||||
var name = ""
|
||||
fun get(t: Any?, p: PropertyMetadata): String = name
|
||||
fun propertyDelegated(p: PropertyMetadata) { name = p.name }
|
||||
}
|
||||
|
||||
fun foo() = Delegate()
|
||||
|
||||
class A {
|
||||
val prop by foo()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return if (A().prop == "prop") "OK" else "fail"
|
||||
}
|
||||
Reference in New Issue
Block a user