FIR: remap Java meta-annotations to Kotlin equivalents

This is a direct port of JavaAnnotationMapper from the old frontend.
This commit is contained in:
pyos
2020-12-01 13:13:13 +03:00
committed by Mikhail Glukhikh
parent a9ad85f306
commit 5efe774dba
15 changed files with 181 additions and 90 deletions
@@ -0,0 +1,25 @@
// WITH_REFLECT
// TARGET_BACKEND: JVM
// FILE: Ann1.java
import java.lang.annotation.*;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann1 {}
// FILE: Ann2.java
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
public @interface Ann2 {}
// FILE: box.kt
class C {
@Ann1 @Ann2 val x = 1
}
fun box(): String {
require(C::class.java.getDeclaredField("x")?.getAnnotation(Ann1::class.java) != null) { "no Ann1 on field x" }
require(C::class.java.getDeclaredMethod("getX\$annotations")?.getAnnotation(Ann2::class.java) != null) { "no Ann2 on property x" }
return "OK"
}