FIR IDE: fix bodies calculator for property acessors

This commit is contained in:
Ilya Kirillov
2020-10-13 22:30:10 +03:00
parent ab4faa52f0
commit a585d20639
@@ -54,17 +54,19 @@ internal object FirLazyBodiesCalculator {
val rawFirBuilder = createRawFirBuilder(firProperty) val rawFirBuilder = createRawFirBuilder(firProperty)
val newProperty = rawFirBuilder.buildPropertyWithBody(firProperty.psi as KtProperty) val newProperty = rawFirBuilder.buildPropertyWithBody(firProperty.psi as KtProperty)
newProperty.apply {
getter?.takeIf { it.body is FirLazyBlock }?.let { getter -> firProperty.getter?.takeIf { it.body is FirLazyBlock }?.let { getter ->
val newGetter = newProperty.getter!! val newGetter = newProperty.getter!!
getter.replaceBody(newGetter.body) getter.replaceBody(newGetter.body)
getter.replaceContractDescription(newGetter.contractDescription) getter.replaceContractDescription(newGetter.contractDescription)
} }
setter?.takeIf { it.body is FirLazyBlock }?.let { setter ->
firProperty.setter?.takeIf { it.body is FirLazyBlock }?.let { setter ->
val newSetter = newProperty.setter!! val newSetter = newProperty.setter!!
setter.replaceBody(newSetter.body) setter.replaceBody(newSetter.body)
setter.replaceContractDescription(newSetter.contractDescription) setter.replaceContractDescription(newSetter.contractDescription)
} }
if (firProperty.initializer is FirLazyExpression) { if (firProperty.initializer is FirLazyExpression) {
firProperty.replaceInitializer(newProperty.initializer) firProperty.replaceInitializer(newProperty.initializer)
} }
@@ -75,7 +77,6 @@ internal object FirLazyBodiesCalculator {
delegate.replaceExpression(newDelegate.expression) delegate.replaceExpression(newDelegate.expression)
} }
} }
}
fun needCalculatingLazyBodyForProperty(firProperty: FirProperty): Boolean = fun needCalculatingLazyBodyForProperty(firProperty: FirProperty): Boolean =
firProperty.getter?.body is FirLazyBlock firProperty.getter?.body is FirLazyBlock