c922484758
The current backend uses direct field access to the backing field
instead of calling the companion object accessor, which calls
an accessibility bridge, which then gets the field for code such as:
```
class A {
companion object {
val s: String = "OK"
}
// f uses direct access to the A.s backing field.
fun f() = s
}
```
This change does the same for the IR backend.
38 lines
770 B
Kotlin
Vendored
38 lines
770 B
Kotlin
Vendored
class A {
|
|
companion object {
|
|
val s = "OK"
|
|
var v = "NOT OK"
|
|
}
|
|
|
|
fun f(): String = s
|
|
|
|
fun g() {
|
|
v = "OK"
|
|
}
|
|
|
|
inline fun i(j: () -> Unit) {
|
|
j()
|
|
}
|
|
|
|
fun h() {
|
|
i {
|
|
s
|
|
v = "OK"
|
|
}
|
|
}
|
|
}
|
|
|
|
// One direct `A.s` access in `f`.
|
|
// One direct `A.s` access in the accessibility bridge `access$getS$cp`.
|
|
// One direct `A.s` access in `h`.
|
|
// 3 GETSTATIC A.s
|
|
|
|
// One direct `A.v` set in `g`.
|
|
// One direct `A.v` set in the accessibility bridge `access$setV$cp`.
|
|
// One direct `A.v` set in `A.<clinit>`
|
|
// One direct `A.v` set in `h`.
|
|
// 4 PUTSTATIC A.v
|
|
|
|
// No calls to the getter/setter on the companion object.
|
|
// 0 INVOKEVIRTUAL A\$Companion.getS
|
|
// 0 INVOKEVIRTUAL A\$Companion.setV |