Generate container class for repeatable annotations

#KT-12794
This commit is contained in:
Alexander Udalov
2021-07-20 23:02:38 +02:00
parent 87130edfa2
commit 92a73d7636
21 changed files with 652 additions and 42 deletions
@@ -0,0 +1,45 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// JVM_TARGET: 1.8
package test
@Repeatable
annotation class A(val value: String)
@A("class1") @A("class2")
class Z @A("constructor1") @A("constructor2") constructor() {
@A("nestedClass1") @A("nestedClass2")
annotation class Nested
@A("memberFunction1") @A("memberFunction2")
fun memberFunction() {}
@A("memberProperty1") @A("memberProperty2")
var memberProperty: Int
@A("propertyGetter1") @A("propertyGetter2")
get() = 0
@A("propertySetter1") @A("propertySetter2")
set(value) {}
}
@A("topLevelFunction1") @A("topLevelFunction2")
fun topLevelFunction2(
@A("parameter1") @A("parameter2")
parameter: String
) {}
@A("topLevelProperty1") @A("topLevelProperty2")
var String.z: Z
@A("propertyGetter1") @A("propertyGetter2")
get() = Z()
@A("propertySetter1") @A("propertySetter2")
set(value) {}
@get:A("useSitePropertyGetter1")
@get:A("useSitePropertyGetter2")
@field:A("field1")
@field:A("field2")
val o: String = ""
@@ -0,0 +1,51 @@
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/A$Container {
// source: 'kotlinAnnotation.kt'
public abstract method value(): test.A[]
public inner class test/A$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/A {
// source: 'kotlinAnnotation.kt'
public abstract method value(): java.lang.String
public inner class test/A$Container
}
@kotlin.Metadata
public final class test/KotlinAnnotationKt {
// source: 'kotlinAnnotation.kt'
private final static @test.A$Container(value=[test.A(value="field1"), test.A(value="field2")]) @org.jetbrains.annotations.NotNull field o: java.lang.String
static method <clinit>(): void
public final static @test.A$Container(value=[test.A(value="useSitePropertyGetter1"), test.A(value="useSitePropertyGetter2")]) @org.jetbrains.annotations.NotNull method getO(): java.lang.String
public synthetic deprecated static @test.A$Container(value=[test.A(value="topLevelProperty1"), test.A(value="topLevelProperty2")]) method getZ$annotations(p0: java.lang.String): void
public final static @test.A$Container(value=[test.A(value="propertyGetter1"), test.A(value="propertyGetter2")]) @org.jetbrains.annotations.NotNull method getZ(@org.jetbrains.annotations.NotNull p0: java.lang.String): test.Z
public final static @test.A$Container(value=[test.A(value="propertySetter1"), test.A(value="propertySetter2")]) method setZ(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: test.Z): void
public final static @test.A$Container(value=[test.A(value="topLevelFunction1"), test.A(value="topLevelFunction2")]) method topLevelFunction2(@test.A$Container(value=[test.A(value="parameter1"), test.A(value="parameter2")]) @org.jetbrains.annotations.NotNull p0: java.lang.String): void
public inner class test/A$Container
}
@test.A$Container(value=[test.A(value="nestedClass1"), test.A(value="nestedClass2")])
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/Z$Nested {
// source: 'kotlinAnnotation.kt'
public inner class test/A$Container
public inner class test/Z$Nested
}
@test.A$Container(value=[test.A(value="class1"), test.A(value="class2")])
@kotlin.Metadata
public final class test/Z {
// source: 'kotlinAnnotation.kt'
public @test.A$Container(value=[test.A(value="constructor1"), test.A(value="constructor2")]) method <init>(): void
public synthetic deprecated static @test.A$Container(value=[test.A(value="memberProperty1"), test.A(value="memberProperty2")]) method getMemberProperty$annotations(): void
public final @test.A$Container(value=[test.A(value="propertyGetter1"), test.A(value="propertyGetter2")]) method getMemberProperty(): int
public final @test.A$Container(value=[test.A(value="memberFunction1"), test.A(value="memberFunction2")]) method memberFunction(): void
public final @test.A$Container(value=[test.A(value="propertySetter1"), test.A(value="propertySetter2")]) method setMemberProperty(p0: int): void
public inner class test/A$Container
public inner class test/Z$Nested
}
@@ -0,0 +1,17 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// JVM_TARGET: 1.8
package test
@Repeatable
@java.lang.annotation.Repeatable(As::class)
annotation class A(val value: String)
annotation class As(val value: Array<A>)
@A("a1")
@A("a2")
class Z
@@ -0,0 +1,22 @@
@kotlin.annotation.Repeatable
@java.lang.annotation.Repeatable(value=test.As::class)
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/A {
// source: 'kotlinAnnotationWithBothRepeatables.kt'
public abstract method value(): java.lang.String
}
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/As {
// source: 'kotlinAnnotationWithBothRepeatables.kt'
public abstract method value(): test.A[]
}
@test.As(value=[test.A(value="a1"), test.A(value="a2")])
@kotlin.Metadata
public final class test/Z {
// source: 'kotlinAnnotationWithBothRepeatables.kt'
public method <init>(): void
}
@@ -0,0 +1,17 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// JVM_TARGET: 1.8
@file:A("file1")
@file:A("file2")
package test
@Repeatable
@Target(AnnotationTarget.FILE, AnnotationTarget.TYPEALIAS)
annotation class A(val value: String)
@A("typealias1")
@A("typealias2")
typealias TA<X> = List<X>
@@ -0,0 +1,28 @@
@kotlin.annotation.Target(allowedTargets=[FILE, TYPEALIAS])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[])
@kotlin.Metadata
public annotation class test/A$Container {
// source: 'kotlinSpecificTargets.kt'
public abstract method value(): test.A[]
public inner class test/A$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Target(allowedTargets=[FILE, TYPEALIAS])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[])
@kotlin.Metadata
public annotation class test/A {
// source: 'kotlinSpecificTargets.kt'
public abstract method value(): java.lang.String
public inner class test/A$Container
}
@test.A$Container(value=[test.A(value="file1"), test.A(value="file2")])
@kotlin.Metadata
public final class test/KotlinSpecificTargetsKt {
// source: 'kotlinSpecificTargets.kt'
public synthetic deprecated static @test.A$Container(value=[test.A(value="typealias1"), test.A(value="typealias2")]) method TA$annotations(): void
public inner class test/A$Container
}
@@ -0,0 +1,26 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// JVM_TARGET: 1.8
package test
@Repeatable
annotation class A(val value: String)
@Repeatable
annotation class B(val value: String)
@Repeatable
annotation class C(val value: String)
annotation class Z(val value: String)
// Expected annotation order (as in Java): all @A, then all @B, then @Z, then all @C.
@A("a1")
@B("b1")
@A("a2")
@Z("z")
@C("c1")
@C("c2")
@B("b2")
class Test
@@ -0,0 +1,70 @@
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/A$Container {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): test.A[]
public inner class test/A$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/A {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): java.lang.String
public inner class test/A$Container
}
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/B$Container {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): test.B[]
public inner class test/B$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/B {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): java.lang.String
public inner class test/B$Container
}
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/C$Container {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): test.C[]
public inner class test/C$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/C {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): java.lang.String
public inner class test/C$Container
}
@test.A$Container(value=[test.A(value="a1"), test.A(value="a2")])
@test.B$Container(value=[test.B(value="b1"), test.B(value="b2")])
@test.Z(value="z")
@test.C$Container(value=[test.C(value="c1"), test.C(value="c2")])
@kotlin.Metadata
public final class test/Test {
// source: 'multipleRepeatableOrder.kt'
public method <init>(): void
public inner class test/A$Container
public inner class test/B$Container
public inner class test/C$Container
}
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class test/Z {
// source: 'multipleRepeatableOrder.kt'
public abstract method value(): java.lang.String
}
@@ -0,0 +1,28 @@
// !LANGUAGE: +RepeatableAnnotations
// TARGET_BACKEND: JVM_IR
// WITH_RUNTIME
// FULL_JDK
// JVM_TARGET: 1.8
@Repeatable
annotation class RetentionRuntime
@Repeatable
@Retention(AnnotationRetention.BINARY)
annotation class RetentionBinary
@Repeatable
@Retention(AnnotationRetention.SOURCE)
annotation class RetentionSource
@Repeatable
@Target(AnnotationTarget.CLASS)
annotation class TargetClassOnly
@Repeatable
@Target(AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.TYPE)
annotation class TargetAnnotationClassAndTypeOnly
@Repeatable
@Target()
annotation class TargetEmpty
@@ -0,0 +1,111 @@
@kotlin.annotation.Retention(value=BINARY)
@java.lang.annotation.Retention(value=CLASS)
@kotlin.Metadata
public annotation class RetentionBinary$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): RetentionBinary[]
public inner class RetentionBinary$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Retention(value=BINARY)
@java.lang.annotation.Retention(value=CLASS)
@kotlin.Metadata
public annotation class RetentionBinary {
// source: 'retentionAndTarget.kt'
public inner class RetentionBinary$Container
}
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class RetentionRuntime$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): RetentionRuntime[]
public inner class RetentionRuntime$Container
}
@kotlin.annotation.Repeatable
@java.lang.annotation.Retention(value=RUNTIME)
@kotlin.Metadata
public annotation class RetentionRuntime {
// source: 'retentionAndTarget.kt'
public inner class RetentionRuntime$Container
}
@kotlin.annotation.Retention(value=SOURCE)
@java.lang.annotation.Retention(value=SOURCE)
@kotlin.Metadata
public annotation class RetentionSource$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): RetentionSource[]
public inner class RetentionSource$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Retention(value=SOURCE)
@java.lang.annotation.Retention(value=SOURCE)
@kotlin.Metadata
public annotation class RetentionSource {
// source: 'retentionAndTarget.kt'
public inner class RetentionSource$Container
}
@kotlin.annotation.Target(allowedTargets=[ANNOTATION_CLASS, TYPE])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[ANNOTATION_TYPE, TYPE_USE])
@kotlin.Metadata
public annotation class TargetAnnotationClassAndTypeOnly$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): TargetAnnotationClassAndTypeOnly[]
public inner class TargetAnnotationClassAndTypeOnly$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Target(allowedTargets=[ANNOTATION_CLASS, TYPE])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[ANNOTATION_TYPE, TYPE_USE])
@kotlin.Metadata
public annotation class TargetAnnotationClassAndTypeOnly {
// source: 'retentionAndTarget.kt'
public inner class TargetAnnotationClassAndTypeOnly$Container
}
@kotlin.annotation.Target(allowedTargets=[CLASS])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[TYPE])
@kotlin.Metadata
public annotation class TargetClassOnly$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): TargetClassOnly[]
public inner class TargetClassOnly$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Target(allowedTargets=[CLASS])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[TYPE])
@kotlin.Metadata
public annotation class TargetClassOnly {
// source: 'retentionAndTarget.kt'
public inner class TargetClassOnly$Container
}
@kotlin.annotation.Target(allowedTargets=[])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[])
@kotlin.Metadata
public annotation class TargetEmpty$Container {
// source: 'retentionAndTarget.kt'
public abstract method value(): TargetEmpty[]
public inner class TargetEmpty$Container
}
@kotlin.annotation.Repeatable
@kotlin.annotation.Target(allowedTargets=[])
@java.lang.annotation.Retention(value=RUNTIME)
@java.lang.annotation.Target(value=[])
@kotlin.Metadata
public annotation class TargetEmpty {
// source: 'retentionAndTarget.kt'
public inner class TargetEmpty$Container
}