Files
kotlin-fork/compiler/testData/writeFlags/property/classObject/rename/delegatedAndDelegated.kt
T
Alexander Udalov e22594acde JVM IR: slightly change field renaming convention implementation
Prefer to rename fields from the class, not from the companion, to be
more in line with the old backend's behavior. This has no effect on the
behavior of current tests but removes differences in metadata (since
metadata has information about every property->field mapping) in some of
them
2019-04-30 13:15:29 +02:00

34 lines
786 B
Kotlin
Vendored

import kotlin.reflect.KProperty
public open class TestDelegate<T: Any>(private val initializer: () -> T) {
private var value: T? = null
operator open fun getValue(thisRef: Any?, desc: KProperty<*>): T {
if (value == null) {
value = initializer()
}
return value!!
}
operator open fun setValue(thisRef: Any?, desc: KProperty<*>, svalue : T) {
value = svalue
}
}
class Test {
public val prop: Int by TestDelegate({10})
companion object {
public var prop: Int by TestDelegate({10})
}
}
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop$delegate$1
// FLAGS: ACC_PRIVATE, ACC_FINAL
// TESTED_OBJECT_KIND: property
// TESTED_OBJECTS: Test, prop$delegate
// FLAGS: ACC_STATIC, ACC_PRIVATE, ACC_FINAL