[JVM_IR] Optimize properties delegated to const val
We can omit `get` call to delegated property and inline constant value directly. If we are not going to do that, we can get a runtime exception because all usages of const property will be inlined and the property itself will be dropped. #KT-63567 Fixed #KT-63580 Fixed
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
// WITH_STDLIB
|
||||
|
||||
var sideEffect = "Fail"
|
||||
|
||||
object Property {
|
||||
init {
|
||||
sideEffect = "OK"
|
||||
}
|
||||
|
||||
const val PROPERTY_VALUE: String = "O"
|
||||
}
|
||||
|
||||
const val TOP_LEVEL_PROPERTY_VALUE: String = "K"
|
||||
|
||||
val value1: String by Property::PROPERTY_VALUE
|
||||
val value2: String by ::TOP_LEVEL_PROPERTY_VALUE
|
||||
|
||||
fun box(): String {
|
||||
if (sideEffect != "OK") return "Side effect wasn't executed"
|
||||
return value1 + value2
|
||||
}
|
||||
Reference in New Issue
Block a user