diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt index 19a59ec00c0..56deb9464f7 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/LateinitLowering.kt @@ -48,6 +48,7 @@ open class LateinitLowering(val context: CommonBackendContext) : FileLoweringPas }.apply { parent = originalField.parent correspondingPropertySymbol = originalField.correspondingPropertySymbol + annotations += originalField.annotations } } } diff --git a/compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt b/compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt new file mode 100644 index 00000000000..8878e9d07ee --- /dev/null +++ b/compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt @@ -0,0 +1,15 @@ +// WITH_REFLECT +// TARGET_BACKEND: JVM + +@Target(AnnotationTarget.FIELD) +annotation class Ann + +class C { + @Ann + lateinit var x0: String +} + +fun box(): String { + require(C::class.java.getDeclaredField("x0")?.getAnnotation(Ann::class.java) != null) + return "OK" +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 52aa8b30d5f..54ec4b2c6e0 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -76,6 +76,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitAccessors.kt"); } + @TestMetadata("annotationsOnLateinitFields.kt") + public void testAnnotationsOnLateinitFields() throws Exception { + runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt"); + } + @TestMetadata("annotationsOnNonExistentAccessors.kt") public void testAnnotationsOnNonExistentAccessors() throws Exception { runTest("compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 32a9059c1d0..e1d28260c61 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -81,6 +81,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitAccessors.kt"); } + @TestMetadata("annotationsOnLateinitFields.kt") + public void testAnnotationsOnLateinitFields() throws Exception { + runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt"); + } + @TestMetadata("annotationsOnNonExistentAccessors.kt") public void testAnnotationsOnNonExistentAccessors() throws Exception { runTest("compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 337c3b63a0f..4fddd824439 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -76,6 +76,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitAccessors.kt"); } + @TestMetadata("annotationsOnLateinitFields.kt") + public void testAnnotationsOnLateinitFields() throws Exception { + runTest("compiler/testData/codegen/box/annotations/annotationsOnLateinitFields.kt"); + } + @TestMetadata("annotationsOnNonExistentAccessors.kt") public void testAnnotationsOnNonExistentAccessors() throws Exception { runTest("compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt");