Kapt+JVM_IR: generate stub bodies for property accessors

Similarly to how stub bodies are generated for functions in the kapt
mode (see `BodyGenerator.generateFunctionBody`).

This is more useful then not generating bodies at all, because otherwise
in the -Xjvm-default=all/all-compatibility modes it would be difficult
to differentiate functions with default implementations from the ones
without (because they all would lack body and thus be generated as
abstract into the resulting Java stub).

The effect of this change is pretty minor, so there's no YT issue. But
it fixes light analysis tests run with JVM_IR in
`codegen/box/jvm8/defaults`, because now there's no difference between
full analysis and light analysis for interfaces with default methods in
new modes.
This commit is contained in:
Alexander Udalov
2023-06-01 17:39:21 +02:00
parent 4ac6f01d31
commit f56bbd68d7
@@ -129,14 +129,12 @@ internal class FunctionGenerator(declarationGenerator: DeclarationGenerator) : D
irAccessor, ktAccessor ?: ktProperty, ktProperty.receiverTypeReference,
ktProperty.contextReceivers.mapNotNull { it.typeReference() }
)
if (context.configuration.generateBodies) {
val ktBodyExpression = ktAccessor?.bodyExpression
irAccessor.body =
if (ktBodyExpression != null)
createBodyGenerator(irAccessor.symbol).generateFunctionBody(ktBodyExpression)
else
generateDefaultAccessorBody(descriptor, irAccessor)
}
val ktBodyExpression = ktAccessor?.bodyExpression
irAccessor.body =
if (ktBodyExpression != null)
createBodyGenerator(irAccessor.symbol).generateFunctionBody(ktBodyExpression)
else
generateDefaultAccessorBody(descriptor, irAccessor)
}
fun generateDefaultAccessorForPrimaryConstructorParameter(
@@ -154,7 +152,7 @@ internal class FunctionGenerator(declarationGenerator: DeclarationGenerator) : D
accessor: PropertyAccessorDescriptor,
irAccessor: IrSimpleFunction
): IrBlockBody? =
if (accessor.modality == Modality.ABSTRACT || accessor.correspondingProperty.isExpect)
if (accessor.modality == Modality.ABSTRACT || accessor.correspondingProperty.isExpect || context.configuration.skipBodies)
null
else
when (accessor) {