Files
kotlin-fork/compiler/testData/codegen/box/delegatedProperty/delegateToAnother/kt49793_interfaceCompanionObject.kt
T
Alexander Udalov 4df937ff7f JVM IR: keep property for $receiver field of optimized delegated properties
For properties which delegate to other property via the getValue
operator from stdlib (see KT-39054), we generate `$receiver` field which
stores the receiver of the property reference used in the delegate. The
problem was that this backing field was missing `correspondingProperty`.
It's needed because it is used as a map key to store static fields in
`JvmCachedDeclarations.getStaticBackingField`. If it's null, accesses to
the static $receiver fields are not remapped correctly in
`RemapObjectFieldAccesses` and
`MoveOrCopyCompanionObjectFieldsLowering`, which led to ICCE or NSFE.

 #KT-49793 Fixed
2021-11-26 19:21:16 +01:00

19 lines
333 B
Kotlin
Vendored

// WITH_STDLIB
class Z(var x: String = "Fail")
operator fun Z.getValue(x: Any?, y: Any?): Z = this
operator fun Z.setValue(x: Any?, y: Any?, value: Z) { this.x = value.x }
interface O {
companion object {
val instance: Z by Z()
var y by instance::x
}
}
fun box(): String {
O.y = "OK"
return O.y
}