Files
kotlin-fork/compiler/testData/codegen/box/fieldRename/delegates.kt
T
Alexander Udalov b68e47f705 Move JVM-specific annotations out of built-ins
Move 'volatile' and 'synchronized' to package 'kotlin' in stdlib. Also delete
'atomic', since its support was never implemented
2014-03-02 19:54:55 +04:00

27 lines
586 B
Kotlin

public open class TestDelegate<T: Any>(private val initializer: () -> T) {
private var value: T? = null
public open fun get(thisRef: Any?, desc: PropertyMetadata): T {
if (value == null) {
value = initializer()
}
return value!!
}
public open fun set(thisRef: Any?, desc: PropertyMetadata, svalue : T) {
value = svalue
}
}
class A {}
class B {}
public val A.s: String by TestDelegate( {"OK2"})
public val B.s: String by TestDelegate( {"OK"})
fun box() : String {
if (A().s != "OK2") return "fail1"
return B().s
}