mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
Final default properties accessors that access a backing field on the same class can be replaced by direct field use. Perform the optimization late in the pipeline to allow lowerings to expose more opportunities for optimizations.
29 lines
470 B
Kotlin
Vendored
29 lines
470 B
Kotlin
Vendored
val x = 1
|
|
|
|
class A {
|
|
val b = 2
|
|
}
|
|
|
|
fun box(): Int {
|
|
when ("abc".length) {
|
|
x -> return 0
|
|
else -> A()
|
|
}
|
|
|
|
if (x == 0) return 1
|
|
|
|
val a = A()
|
|
when ("cde".length) {
|
|
a.b -> return 0
|
|
else -> A()
|
|
}
|
|
|
|
if (a.b == 0) return 1
|
|
|
|
return 2
|
|
}
|
|
|
|
/* 1 GETSTATIC is located within `x` public getter, other 2 are accesses that should not be inlined */
|
|
// 3 GETSTATIC NoInlineNonConstKt\.x : I
|
|
// 2 INVOKEVIRTUAL A\.getB \(\)I
|