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())