JVM IR: fix VerifyError on annotated annotation properties

The problem was that we tried to generate an `$annotations` method for a
property declared in an annotation class. That method is final and has a
body, which is not allowed in annotation classes. Now we're generating
this method in the separate `$DefaultImpls` class as for properties in
interfaces.

Note that the added test still doesn't find any annotations because the
proper support is needed in reflection (KT-22463). Currently it only
checks that no VerifyError happens.
This commit is contained in:
Alexander Udalov
2019-11-14 17:04:38 +01:00
parent 994d4e081b
commit cdb7703947
6 changed files with 74 additions and 26 deletions
@@ -0,0 +1,13 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
@Target(AnnotationTarget.PROPERTY)
annotation class Anno(val value: String)
annotation class M(@Anno("OK") val result: Int)
fun box(): String =
M::class.java.getAnnotation(Anno::class.java)?.value
// TODO: fix KT-22463 and enable this test
// ?: "Fail: no annotation"
?: "OK"