diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java index 9688d55dfed..5e7dd842379 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirBlackBoxCodegenTestGenerated.java @@ -166,6 +166,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnProperty.kt"); } + @Test + @TestMetadata("javaAnnotationOnSecondaryConstructorOfLocalClass.kt") + public void testJavaAnnotationOnSecondaryConstructorOfLocalClass() throws Exception { + runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt"); + } + @Test @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt index d881b247b05..29b2aa3cee0 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LocalDeclarationsLowering.kt @@ -726,6 +726,8 @@ class LocalDeclarationsLowering( ) newDeclaration.recordTransformedValueParameters(constructorContext) + newDeclaration.annotations = oldDeclaration.annotations + newDeclaration.metadata = oldDeclaration.metadata transformedDeclarations[oldDeclaration] = newDeclaration diff --git a/compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt b/compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt new file mode 100644 index 00000000000..c0b6f0e12fa --- /dev/null +++ b/compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt @@ -0,0 +1,19 @@ +// WITH_REFLECT +// TARGET_BACKEND: JVM +// FILE: Ann.java +import java.lang.annotation.*; + +@Target({ElementType.CONSTRUCTOR}) +@Retention(RetentionPolicy.RUNTIME) +public @interface Ann {} + +// FILE: box.kt +fun box(): String { + class C(val x: String, val y: String) { + @Ann + constructor(v: String): this(v, v) + } + + require(C::class.java.getDeclaredConstructor(String::class.java).getAnnotation(Ann::class.java) != null) { "no Ann on constructor" } + return "OK" +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 53a0e386c94..bd5d4247a3d 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -166,6 +166,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnProperty.kt"); } + @Test + @TestMetadata("javaAnnotationOnSecondaryConstructorOfLocalClass.kt") + public void testJavaAnnotationOnSecondaryConstructorOfLocalClass() throws Exception { + runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt"); + } + @Test @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index a25a954c734..5cf08663364 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -166,6 +166,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnProperty.kt"); } + @Test + @TestMetadata("javaAnnotationOnSecondaryConstructorOfLocalClass.kt") + public void testJavaAnnotationOnSecondaryConstructorOfLocalClass() throws Exception { + runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt"); + } + @Test @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 264f65f01a1..7dc10e9522b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -152,6 +152,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnProperty.kt"); } + @TestMetadata("javaAnnotationOnSecondaryConstructorOfLocalClass.kt") + public void testJavaAnnotationOnSecondaryConstructorOfLocalClass() throws Exception { + runTest("compiler/testData/codegen/box/annotations/javaAnnotationOnSecondaryConstructorOfLocalClass.kt"); + } + @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { runTest("compiler/testData/codegen/box/annotations/javaNegativePropertyAsAnnotationParameter.kt");