JVM IR: fix condition in Documented annotation generation
This commit is contained in:
+3
-5
@@ -133,11 +133,9 @@ private class AdditionalClassAnnotationLowering(private val context: JvmBackendC
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun generateDocumentedAnnotation(irClass: IrClass) {
|
private fun generateDocumentedAnnotation(irClass: IrClass) {
|
||||||
if (irClass.hasAnnotation(KotlinBuiltIns.FQ_NAMES.mustBeDocumented) &&
|
if (!irClass.hasAnnotation(KotlinBuiltIns.FQ_NAMES.mustBeDocumented) ||
|
||||||
!irClass.hasAnnotation(FqName("java.lang.annotation.Documented"))
|
irClass.hasAnnotation(FqName("java.lang.annotation.Documented"))
|
||||||
) {
|
) return
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
irClass.annotations.add(
|
irClass.annotations.add(
|
||||||
IrConstructorCallImpl.fromSymbolOwner(
|
IrConstructorCallImpl.fromSymbolOwner(
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented
|
||||||
|
|
||||||
|
annotation class NoDocumented
|
||||||
|
|
||||||
|
@MustBeDocumented
|
||||||
|
annotation class ExplicitMustBeDocumented
|
||||||
|
|
||||||
|
@Documented
|
||||||
|
annotation class ExplicitJavaDocumented
|
||||||
|
|
||||||
|
@MustBeDocumented
|
||||||
|
@Documented
|
||||||
|
annotation class ExplicitBoth
|
||||||
|
|
||||||
|
inline fun <reified A> isDocumented(): Boolean =
|
||||||
|
A::class.java.getDeclaredAnnotation(Documented::class.java) != null
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
if (isDocumented<NoDocumented>()) return "Fail NoDocumented"
|
||||||
|
if (!isDocumented<ExplicitMustBeDocumented>()) return "Fail ExplicitMustBeDocumented"
|
||||||
|
if (!isDocumented<ExplicitJavaDocumented>()) return "Fail ExplicitJavaDocumented"
|
||||||
|
if (!isDocumented<ExplicitBoth>()) return "Fail ExplicitBoth"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -136,6 +136,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/mustBeDocumented.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedAnnotation.kt")
|
@TestMetadata("nestedAnnotation.kt")
|
||||||
public void testNestedAnnotation() throws Exception {
|
public void testNestedAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||||
|
|||||||
+5
@@ -141,6 +141,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/mustBeDocumented.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedAnnotation.kt")
|
@TestMetadata("nestedAnnotation.kt")
|
||||||
public void testNestedAnnotation() throws Exception {
|
public void testNestedAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||||
|
|||||||
+5
@@ -136,6 +136,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/mustBeDocumented.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedAnnotation.kt")
|
@TestMetadata("nestedAnnotation.kt")
|
||||||
public void testNestedAnnotation() throws Exception {
|
public void testNestedAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||||
|
|||||||
+5
@@ -136,6 +136,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
runTest("compiler/testData/codegen/box/annotations/kt10136.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("mustBeDocumented.kt")
|
||||||
|
public void testMustBeDocumented() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/annotations/mustBeDocumented.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("nestedAnnotation.kt")
|
@TestMetadata("nestedAnnotation.kt")
|
||||||
public void testNestedAnnotation() throws Exception {
|
public void testNestedAnnotation() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
runTest("compiler/testData/codegen/box/annotations/nestedAnnotation.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user