JVM_IR: don't generate repeated ElementType values in @Target

This commit is contained in:
Dmitry Petrov
2020-07-28 12:09:37 +03:00
parent c065210b56
commit 4fdccb3b35
6 changed files with 44 additions and 1 deletions
@@ -61,6 +61,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/annotations/annotationProperty.kt");
}
@TestMetadata("annotationTargets.kt")
public void testAnnotationTargets() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationTargets.kt");
}
@TestMetadata("annotationWithKotlinProperty.kt")
public void testAnnotationWithKotlinProperty() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationWithKotlinProperty.kt");
@@ -192,7 +192,7 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
?: throw AssertionError("No annotation target map for JVM target $jvmTarget")
val targets = irClass.applicableTargetSet() ?: return
val javaTargets = targets.mapNotNull { annotationTargetMap[it] }
val javaTargets = targets.mapNotNull { annotationTargetMap[it] }.toSet()
val vararg = IrVarargImpl(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
@@ -0,0 +1,23 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FULL_JDK
@Target(
AnnotationTarget.FUNCTION, AnnotationTarget.FIELD,
AnnotationTarget.PROPERTY, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.PROPERTY_SETTER
)
public annotation class TestAnn
fun box(): String {
val testAnnClass = TestAnn::class.java
val targetAnn = testAnnClass.getAnnotation(java.lang.annotation.Target::class.java)
val targets = targetAnn.value
if (targets.size != 2) {
return targets.toList().toString()
}
if (targets.toSet() != setOf(java.lang.annotation.ElementType.FIELD, java.lang.annotation.ElementType.METHOD)) {
return targets.toList().toString()
}
return "OK"
}
@@ -61,6 +61,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/annotations/annotationProperty.kt");
}
@TestMetadata("annotationTargets.kt")
public void testAnnotationTargets() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationTargets.kt");
}
@TestMetadata("annotationWithKotlinProperty.kt")
public void testAnnotationWithKotlinProperty() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationWithKotlinProperty.kt");
@@ -61,6 +61,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/annotations/annotationProperty.kt");
}
@TestMetadata("annotationTargets.kt")
public void testAnnotationTargets() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationTargets.kt");
}
@TestMetadata("annotationWithKotlinProperty.kt")
public void testAnnotationWithKotlinProperty() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationWithKotlinProperty.kt");
@@ -61,6 +61,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/annotations/annotationProperty.kt");
}
@TestMetadata("annotationTargets.kt")
public void testAnnotationTargets() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationTargets.kt");
}
@TestMetadata("annotationWithKotlinProperty.kt")
public void testAnnotationWithKotlinProperty() throws Exception {
runTest("compiler/testData/codegen/box/annotations/annotationWithKotlinProperty.kt");