From c5f6c2acbd45681bb947a8b314f399ba6df302d6 Mon Sep 17 00:00:00 2001 From: Pavel Kunyavskiy Date: Wed, 27 Oct 2021 11:47:03 +0300 Subject: [PATCH] Better pre-1.6.20 compatibility fix for AnnotationImplementation ^KT-49428 --- .../common/lower/AnnotationImplementationTransformer.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AnnotationImplementationTransformer.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AnnotationImplementationTransformer.kt index e0814abeff1..4a551431929 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AnnotationImplementationTransformer.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/AnnotationImplementationTransformer.kt @@ -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())