JVM_IR: remove constructors of nested annotations
This commit is contained in:
+5
-11
@@ -22,19 +22,13 @@ internal val annotationPhase = makeIrFilePhase<JvmBackendContext>(
|
||||
description = "Remove constructors of annotation classes"
|
||||
)
|
||||
|
||||
/**
|
||||
* Remove the constructors from annotation classes.
|
||||
*/
|
||||
private class AnnotationLowering : FileLoweringPass, IrElementTransformerVoid() {
|
||||
override fun lower(irFile: IrFile) = irFile.transformChildrenVoid(this)
|
||||
|
||||
override fun visitClass(declaration: IrClass): IrStatement {
|
||||
if (!declaration.isAnnotationClass) return super.visitClass(declaration)
|
||||
|
||||
declaration.declarations.removeIf {
|
||||
it is IrConstructor
|
||||
override fun visitClass(declaration: IrClass): IrStatement =
|
||||
declaration.transformPostfix {
|
||||
if (isAnnotationClass) {
|
||||
declarations.removeIf { it is IrConstructor }
|
||||
}
|
||||
}
|
||||
|
||||
return declaration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
annotation class Foo {
|
||||
annotation class Bar
|
||||
}
|
||||
|
||||
@Foo.Bar
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
+5
@@ -136,6 +136,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassPropertyAsParameter.kt")
|
||||
public void testNestedClassPropertyAsParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassPropertyAsParameter.kt");
|
||||
|
||||
+5
@@ -141,6 +141,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassPropertyAsParameter.kt")
|
||||
public void testNestedClassPropertyAsParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassPropertyAsParameter.kt");
|
||||
|
||||
+5
@@ -136,6 +136,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassPropertyAsParameter.kt")
|
||||
public void testNestedClassPropertyAsParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassPropertyAsParameter.kt");
|
||||
|
||||
+5
@@ -136,6 +136,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassPropertyAsParameter.kt")
|
||||
public void testNestedClassPropertyAsParameter() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassPropertyAsParameter.kt");
|
||||
|
||||
Generated
+5
@@ -41,6 +41,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassesInAnnotations.kt")
|
||||
public void testNestedClassesInAnnotations() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt");
|
||||
|
||||
+5
@@ -41,6 +41,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/annotations"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true);
|
||||
}
|
||||
|
||||
@TestMetadata("nestedAnnotation.kt")
|
||||
public void testNestedAnnotation() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClassesInAnnotations.kt")
|
||||
public void testNestedClassesInAnnotations() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/annotations/nestedClassesInAnnotations.kt");
|
||||
|
||||
Reference in New Issue
Block a user