Properly generate annotation classes

This commit is contained in:
Mikhael Bogdanov
2018-05-16 11:57:52 +02:00
parent 893e843648
commit aece29a95b
3 changed files with 24 additions and 2 deletions
@@ -36,6 +36,7 @@ class JvmLower(val context: JvmBackendContext) {
ConstAndJvmFieldPropertiesLowering().lower(irFile)
PropertiesLowering().lower(irFile)
AnnotationLowering().runOnFilePostfix(irFile) //should be run before defaults lowering
//Should be before interface lowering
DefaultArgumentStubGenerator(context, false).runOnFilePostfix(irFile)
@@ -84,9 +84,9 @@ open class FunctionCodegen(private val irFunction: IrFunction, private val class
val deprecation = 0 //TODO
val bridgeFlag = 0 //TODO
val modalityFlag = when ((irFunction as? IrSimpleFunction)?.modality) {
Modality.FINAL -> if (!classCodegen.irClass.isAnnotationClass) Opcodes.ACC_FINAL else 0
Modality.FINAL -> if (!classCodegen.irClass.isAnnotationClass) Opcodes.ACC_FINAL else Opcodes.ACC_ABSTRACT
Modality.ABSTRACT -> Opcodes.ACC_ABSTRACT
else -> if (classCodegen.irClass.isJvmInterface) Opcodes.ACC_ABSTRACT else 0 //TODO transform interface modality on lowering to DefaultImpls
else -> if (classCodegen.irClass.isJvmInterface && irFunction.body == null) Opcodes.ACC_ABSTRACT else 0 //TODO transform interface modality on lowering to DefaultImpls
}
val nativeFlag = if (irFunction.isExternal) Opcodes.ACC_NATIVE else 0
@@ -0,0 +1,21 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.backend.jvm.lower
import org.jetbrains.kotlin.backend.common.ClassLoweringPass
import org.jetbrains.kotlin.ir.declarations.IrClass
import org.jetbrains.kotlin.ir.declarations.IrConstructor
import org.jetbrains.kotlin.ir.util.isAnnotationClass
class AnnotationLowering : ClassLoweringPass {
override fun lower(irClass: IrClass) {
if (!irClass.isAnnotationClass) return
irClass.declarations.removeIf {
it is IrConstructor
}
}
}