[K2] Support serialization of complex annotations
#KT-57611 Fixed
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// TARGET_BACKEND: NATIVE
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class Annotation(val str: String)
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class AnnotationWithAnnotation(val anno: Annotation)
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class AnnotationWithAnnotationWithAnnotation(val anno: AnnotationWithAnnotation)
|
||||
|
||||
@AnnotationWithAnnotation(Annotation("Str" + "ing"))
|
||||
class A
|
||||
|
||||
@AnnotationWithAnnotationWithAnnotation(AnnotationWithAnnotation(Annotation("Str" + "ing")))
|
||||
class B
|
||||
|
||||
// MODULE: main
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+13
@@ -50,6 +50,19 @@ enum class SomeEnum {
|
||||
B;
|
||||
}
|
||||
|
||||
// TODO: can be uncommented after fix KT-57135
|
||||
//@field:BinaryAnnotation("Str" + "ing")
|
||||
//var x: Int = 5
|
||||
|
||||
//object Delegate {
|
||||
// operator fun getValue(instance: Any?, property: Any) : String = ""
|
||||
// operator fun setValue(instance: Any?, property: Any, value: String) {}
|
||||
//}
|
||||
//
|
||||
//@delegate:BinaryAnnotation("Str" + "ing")
|
||||
//val p: String by Delegate
|
||||
|
||||
|
||||
// 7. VALUE_PARAMETER
|
||||
fun @receiver:BinaryAnnotation("Str" + "ing") String.myExtension() { }
|
||||
fun foo(@BinaryAnnotation("Str" + "ing") a: Int) { }
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// TARGET_BACKEND: NATIVE
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class AnnotationWithVararg(vararg val array: String)
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class AnnotationWithArray(val array: Array<String>)
|
||||
|
||||
@AnnotationWithVararg("Str" + "ing", "String2", "String${3}")
|
||||
class A
|
||||
|
||||
@AnnotationWithArray(["Str" + "ing", "String2", "String${3}"])
|
||||
class B
|
||||
|
||||
// MODULE: main
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+23
@@ -0,0 +1,23 @@
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// TARGET_BACKEND: NATIVE
|
||||
|
||||
// MODULE: lib
|
||||
// FILE: lib.kt
|
||||
|
||||
@Target(AnnotationTarget.CLASS)
|
||||
@Retention(AnnotationRetention.BINARY)
|
||||
annotation class AnnotationWithDefault(val str: String = "Str" + "ing")
|
||||
|
||||
@AnnotationWithDefault()
|
||||
class A
|
||||
|
||||
@AnnotationWithDefault("Other")
|
||||
class B
|
||||
|
||||
// MODULE: main
|
||||
// FILE: main.kt
|
||||
|
||||
fun box(): String {
|
||||
return "OK"
|
||||
}
|
||||
Reference in New Issue
Block a user