Better pre-1.6.20 compatibility fix for AnnotationImplementation

^KT-49428
This commit is contained in:
Pavel Kunyavskiy
2021-10-27 11:47:03 +03:00
committed by Space
parent d127815626
commit c5f6c2acbd
@@ -50,9 +50,11 @@ abstract class AnnotationImplementationTransformer(val context: BackendContext,
override fun visitClassNew(declaration: IrClass): IrStatement {
declaration.takeIf { declaration.isAnnotationClass }?.constructors?.singleOrNull()?.apply {
// Compatibility hack. Now, frontend generates constructor body for annotations
// but, if one gets annotation from pre-1.6.20 klib, it would have none, so we need to generate it's body
// Compatibility hack. Now, frontend generates constructor body for annotations and makes them open
// but, if one gets annotation from pre-1.6.20 klib, it would have no constructor body and would be final,
// so we need to fix it
if (body == null) {
declaration.modality = Modality.OPEN
body = context.createIrBuilder(symbol)
.irBlockBody(SYNTHETIC_OFFSET, SYNTHETIC_OFFSET) {
+irDelegatingConstructorCall(context.irBuiltIns.anyClass.owner.constructors.single())