mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 00:21:47 +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.
20 lines
433 B
Kotlin
Vendored
20 lines
433 B
Kotlin
Vendored
package b
|
|
|
|
abstract class B {
|
|
open val propWithFinal: Int
|
|
get() = 1
|
|
|
|
open val propWithNonFinal: Int
|
|
get() = 2
|
|
}
|
|
|
|
abstract class Base: B() {
|
|
override final val propWithFinal: Int = 3
|
|
override val propWithNonFinal: Int = 4
|
|
|
|
fun fooFinal() = this.propWithFinal
|
|
fun fooNonFinal() = this.propWithNonFinal
|
|
}
|
|
|
|
// 2 GETFIELD b/Base.propWithFinal : I
|
|
// 1 INVOKEVIRTUAL b/Base.getPropWithNonFinal \(\)I |