Support preference of TYPE_USE annotations to enhance over others like METHOD, FIELD and VALUE_PARAMETER to avoid double applying them in case of arrays: @NotNull Integer [] (both to the array element and to the entire array)

^KT-24392 Fixed
This commit is contained in:
Victor Petukhov
2020-12-08 18:32:33 +03:00
parent 69f31afecc
commit 857cc92326
8 changed files with 83 additions and 47 deletions
@@ -37,6 +37,7 @@ import org.jetbrains.kotlin.ir.util.defaultType
import org.jetbrains.kotlin.ir.util.getAnnotation
import org.jetbrains.kotlin.ir.util.hasAnnotation
import org.jetbrains.kotlin.ir.util.isAnnotationClass
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
@@ -191,7 +192,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
}
private fun generateTargetAnnotation(irClass: IrClass) {
if (irClass.hasAnnotation(FqName("java.lang.annotation.Target"))) return
if (irClass.hasAnnotation(JvmAnnotationNames.TARGET_ANNOTATION)) return
val annotationTargetMap = annotationTargetMaps[jvmTarget]
?: throw AssertionError("No annotation target map for JVM target $jvmTarget")