Replace get() and set() to getValue() and setValue() (property delegates)

This commit is contained in:
Yan Zhulanow
2015-10-05 20:18:58 +03:00
parent 2fee9d362c
commit 1f2b4e20fe
295 changed files with 718 additions and 511 deletions
@@ -0,0 +1,51 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class CustomDelegate {
fun get(thisRef: Any?, prop: PropertyMetadata): String = prop.name
fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {}
}
class OkDelegate {
fun getValue(thisRef: Any?, prop: PropertyMetadata): String = prop.name
fun setValue(thisRef: Any?, prop: PropertyMetadata, value: String) {}
}
class CustomDelegate2 {
fun get(thisRef: Any?, prop: PropertyMetadata): String = prop.name
fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {}
fun getValue(thisRef: Any?, prop: PropertyMetadata): Int = 5
fun setValue(thisRef: Any?, prop: PropertyMetadata, value: Int) {}
}
class CustomDelegate3 {
fun get(thisRef: Any?, prop: PropertyMetadata): String = prop.name
fun set(thisRef: Any?, prop: PropertyMetadata, value: String) {}
}
fun OkDelegate.get(thisRef: Any?, prop: PropertyMetadata): Int = 4
fun OkDelegate.set(thisRef: Any?, prop: PropertyMetadata, value: Int) {}
fun CustomDelegate3.getValue(thisRef: Any?, prop: PropertyMetadata): Int = 4
fun CustomDelegate3.setValue(thisRef: Any?, prop: PropertyMetadata, value: Int) {}
class Example {
var a by <!DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION, DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION!>CustomDelegate()<!>
val aval by <!DELEGATE_RESOLVED_TO_DEPRECATED_CONVENTION!>CustomDelegate()<!>
var b by OkDelegate()
var c by CustomDelegate2()
var d by CustomDelegate3()
fun test() {
requireString(a)
requireString(aval)
requireString(b)
requireInt(c)
requireInt(d)
}
fun requireString(s: String) {}
fun requireInt(n: Int) {}
}