Files
kotlin-fork/compiler/testData/codegen/box/annotations/mustBeDocumented.kt
T
Alexander Udalov 9f25fdcedc Minor, skip mustBeDocumented.kt for JDK 6 codegen tests
Class.getDeclaredAnnotation is not available before JDK 8
2020-01-31 09:36:17 +01:00

32 lines
809 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// SKIP_JDK6
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"
}