Files
kotlin-fork/compiler/testData/codegen/box/annotations/annotationsOnLateinitAccessors.kt
T
Mads Ager 8e9dfc23b6 FIR: Take targeted annotations into account for metadata
Getter/setter targeted annotations were not correctly reflected
in the kotlin metadata which made them not work with
kotlin-reflect.
2021-03-03 08:48:28 +03:00

32 lines
698 B
Kotlin
Vendored

// WITH_REFLECT
// TARGET_BACKEND: JVM
// Please make sure that this test is consistent with the diagnostic test "annotationsTargetingLateinitAccessor.kt"
import kotlin.reflect.KAnnotatedElement
annotation class Ann
fun check(element: KAnnotatedElement, annotationExists: Boolean) {
require(element.annotations.isNotEmpty() == annotationExists) { "Fail: $element" }
}
class LateinitProperties {
@get:Ann
lateinit var x0: String
@get:Ann
private lateinit var x1: String
fun test() {
check(::x0.getter, annotationExists = true)
check(::x1.getter, annotationExists = false)
}
}
fun box(): String {
LateinitProperties().test()
return "OK"
}