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
This commit is contained in:
Alexander Udalov
2021-11-26 02:48:51 +01:00
parent 29c1fe1be1
commit 4df937ff7f
11 changed files with 168 additions and 0 deletions
@@ -145,6 +145,7 @@ private class PropertyReferenceDelegationTransformer(val context: JvmBackendCont
}.apply {
parent = oldField.parent
initializer = context.irFactory.createExpressionBody(it)
correspondingPropertySymbol = oldField.correspondingPropertySymbol
}
}
val originalThis = parentAsClass.thisReceiver