FIR: record use of backing field symbol to indeed add a backing field

This commit is contained in:
Jinseong Jeon
2020-08-24 10:46:38 -07:00
committed by Mikhail Glukhikh
parent 0cc3762f9a
commit 3e9ac75cfc
5 changed files with 9 additions and 5 deletions
@@ -676,8 +676,10 @@ class Fir2IrDeclarationStorage(
val setter = property.setter
// TODO: this checks are very preliminary, FIR resolve should determine backing field presence itself
if (property.isConst || (property.modality != Modality.ABSTRACT && (irParent !is IrClass || !irParent.isInterface))) {
if (initializer != null || getter is FirDefaultPropertyGetter ||
property.isVar && setter is FirDefaultPropertySetter
if (initializer != null ||
getter is FirDefaultPropertyGetter ||
property.isVar && setter is FirDefaultPropertySetter ||
property.backingFieldSymbol.isReferenced
) {
backingField = createBackingField(
property, IrDeclarationOrigin.PROPERTY_BACKING_FIELD, descriptor,