[IR] Move annotations from original to new constructor declarations.
LocalDeclarationsLowering did not move annotations when creating a new constructor declaration, thereby losing the annotations. Fixes KT-45298
This commit is contained in:
committed by
Alexander Udalov
parent
965c118521
commit
e5631addf3
+6
@@ -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 {
|
||||
|
||||
+2
@@ -726,6 +726,8 @@ class LocalDeclarationsLowering(
|
||||
)
|
||||
newDeclaration.recordTransformedValueParameters(constructorContext)
|
||||
|
||||
newDeclaration.annotations = oldDeclaration.annotations
|
||||
|
||||
newDeclaration.metadata = oldDeclaration.metadata
|
||||
|
||||
transformedDeclarations[oldDeclaration] = newDeclaration
|
||||
|
||||
Vendored
+19
@@ -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"
|
||||
}
|
||||
+6
@@ -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 {
|
||||
|
||||
+6
@@ -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 {
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user