JVM_IR: remove constructors of nested annotations

This commit is contained in:
pyos
2019-12-19 14:43:09 +01:00
committed by max-kammerer
parent 17d2fda946
commit 59f2aa7add
8 changed files with 43 additions and 11 deletions
@@ -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
}
}