d0ed0c4049
- Use direct access to property defined into companion object when it is possible rather than always use an accessor to access the property. - Use direct access will speedup runtime performance. - Avoid to generate useless accessors for companion properties. Fix of https://youtrack.jetbrains.com/issue/KT-14258
40 lines
846 B
Kotlin
Vendored
40 lines
846 B
Kotlin
Vendored
class A {
|
|
|
|
private var foo = 1;
|
|
|
|
fun `access$getFoo$p`(a: A): Int = 1
|
|
fun `access$setFoo$p`(a: A, d: Int) {}
|
|
|
|
//companion backing field accessors
|
|
fun `access$getFoo$cp`(): Int = 1
|
|
fun `access$setFoo$cp`(d: Int) {}
|
|
|
|
val bar = 0
|
|
get() = { field }()
|
|
|
|
//synthetic field convention accessor
|
|
fun `access$getBar$lp`(a: A): Int = 7
|
|
|
|
companion object {
|
|
private var foo = 1
|
|
// Custom getter is needed, otherwise no need to generate getY and setY
|
|
get() = field
|
|
|
|
fun test() {
|
|
{
|
|
foo = 2;
|
|
foo
|
|
}()
|
|
}
|
|
|
|
fun `access$getFoo$p`(p: A.Companion): Int = 1
|
|
fun `access$setFoo$p`(p: A.Companion, d: Int) {}
|
|
}
|
|
|
|
fun test() {
|
|
{
|
|
foo = 2;
|
|
foo + bar
|
|
}()
|
|
}
|
|
} |