Report error if both repeatable annotation and its container are used

#KT-12794
This commit is contained in:
Alexander Udalov
2021-07-24 00:47:35 +02:00
parent b2550f69bc
commit 67128c022a
13 changed files with 833 additions and 12 deletions
@@ -0,0 +1,142 @@
// !LANGUAGE: -RepeatableAnnotations
// FULL_JDK
// FILE: JR.java
import java.lang.annotation.*;
@Repeatable(JR.Container.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface JR {
public @interface Container {
JR[] value();
}
}
// FILE: JS.java
import java.lang.annotation.*;
@Repeatable(JS.Container.class)
@Retention(RetentionPolicy.SOURCE)
public @interface JS {
public @interface Container {
JS[] value();
}
}
// FILE: KR.kt
@java.lang.annotation.Repeatable(KR.Container::class)
@Retention(AnnotationRetention.RUNTIME)
annotation class KR {
annotation class Container(val value: Array<KR>)
}
// FILE: KS.kt
@java.lang.annotation.Repeatable(KS.Container::class)
@Retention(AnnotationRetention.SOURCE)
annotation class KS {
annotation class Container(val value: Array<KS>)
}
// FILE: test.kt
// Java runtime-retained annotation
@JR
@JR.Container()
fun jr1() {}
@JR
@JR.Container()
@JR
fun jr2() {}
@JR
@JR.Container(JR())
@JR
fun jr3() {}
@JR
@JR.Container(JR())
fun jr4() {}
@JR
@JR.Container(JR(), JR())
fun jr5() {}
// Java source-retained annotation
@JS
@JS.Container()
fun js1() {}
@JS
@JS.Container()
@JS
fun js2() {}
@JS
@JS.Container(JS())
@JS
fun js3() {}
@JS
@JS.Container(JS())
fun js4() {}
@JS
@JS.Container(JS(), JS())
fun js5() {}
// Kotlin runtime-retained annotation
@KR.Container([])
@KR
fun kr1() {}
@KR.Container([])
@KR
@KR
fun kr2() {}
@KR
@KR
@KR.Container([KR()])
fun kr3() {}
@KR.Container([KR()])
@KR
fun kr4() {}
@KR
@KR.Container([KR(), KR()])
fun kr5() {}
// Kotlin source-retained annotation
@KS.Container([])
@KS
fun ks1() {}
@KS.Container([])
@KS
@KS
fun ks2() {}
@KS
@KS
@KS.Container([KS()])
fun ks3() {}
@KS.Container([KS()])
@KS
fun ks4() {}
@KS
@KS.Container([KS(), KS()])
fun ks5() {}
@@ -0,0 +1,142 @@
// !LANGUAGE: -RepeatableAnnotations
// FULL_JDK
// FILE: JR.java
import java.lang.annotation.*;
@Repeatable(JR.Container.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface JR {
public @interface Container {
JR[] value();
}
}
// FILE: JS.java
import java.lang.annotation.*;
@Repeatable(JS.Container.class)
@Retention(RetentionPolicy.SOURCE)
public @interface JS {
public @interface Container {
JS[] value();
}
}
// FILE: KR.kt
@java.lang.annotation.Repeatable(KR.Container::class)
@Retention(AnnotationRetention.RUNTIME)
annotation class KR {
annotation class Container(val value: Array<KR>)
}
// FILE: KS.kt
@java.lang.annotation.Repeatable(KS.Container::class)
@Retention(AnnotationRetention.SOURCE)
annotation class KS {
annotation class Container(val value: Array<KS>)
}
// FILE: test.kt
// Java runtime-retained annotation
@JR
@JR.Container()
fun jr1() {}
@JR
@JR.Container()
<!REPEATED_ANNOTATION!>@JR<!>
fun jr2() {}
@JR
@JR.Container(JR())
<!REPEATED_ANNOTATION!>@JR<!>
fun jr3() {}
@JR
@JR.Container(JR())
fun jr4() {}
@JR
@JR.Container(JR(), JR())
fun jr5() {}
// Java source-retained annotation
@JS
@JS.Container()
fun js1() {}
@JS
@JS.Container()
@JS
fun js2() {}
@JS
@JS.Container(JS())
@JS
fun js3() {}
@JS
@JS.Container(JS())
fun js4() {}
@JS
@JS.Container(JS(), JS())
fun js5() {}
// Kotlin runtime-retained annotation
@KR.Container([])
@KR
fun kr1() {}
@KR.Container([])
@KR
<!REPEATED_ANNOTATION!>@KR<!>
fun kr2() {}
@KR
<!REPEATED_ANNOTATION!>@KR<!>
@KR.Container([KR()])
fun kr3() {}
@KR.Container([KR()])
@KR
fun kr4() {}
@KR
@KR.Container([KR(), KR()])
fun kr5() {}
// Kotlin source-retained annotation
@KS.Container([])
@KS
fun ks1() {}
@KS.Container([])
@KS
<!REPEATED_ANNOTATION!>@KS<!>
fun ks2() {}
@KS
<!REPEATED_ANNOTATION!>@KS<!>
@KS.Container([KS()])
fun ks3() {}
@KS.Container([KS()])
@KS
fun ks4() {}
@KS
@KS.Container([KS(), KS()])
fun ks5() {}
@@ -0,0 +1,83 @@
package
@JR @JR.Container(value = {}) public fun jr1(): kotlin.Unit
@JR @JR.Container(value = {}) @JR public fun jr2(): kotlin.Unit
@JR @JR.Container(value = {JR}) @JR public fun jr3(): kotlin.Unit
@JR @JR.Container(value = {JR}) public fun jr4(): kotlin.Unit
@JR @JR.Container(value = {JR, JR}) public fun jr5(): kotlin.Unit
@JS @JS.Container(value = {}) public fun js1(): kotlin.Unit
@JS @JS.Container(value = {}) @JS public fun js2(): kotlin.Unit
@JS @JS.Container(value = {JS}) @JS public fun js3(): kotlin.Unit
@JS @JS.Container(value = {JS}) public fun js4(): kotlin.Unit
@JS @JS.Container(value = {JS, JS}) public fun js5(): kotlin.Unit
@KR.Container(value = {}) @KR public fun kr1(): kotlin.Unit
@KR.Container(value = {}) @KR @KR public fun kr2(): kotlin.Unit
@KR @KR @KR.Container(value = {KR}) public fun kr3(): kotlin.Unit
@KR.Container(value = {KR}) @KR public fun kr4(): kotlin.Unit
@KR @KR.Container(value = {KR, KR}) public fun kr5(): kotlin.Unit
@KS.Container(value = {}) @KS public fun ks1(): kotlin.Unit
@KS.Container(value = {}) @KS @KS public fun ks2(): kotlin.Unit
@KS @KS @KS.Container(value = {KS}) public fun ks3(): kotlin.Unit
@KS.Container(value = {KS}) @KS public fun ks4(): kotlin.Unit
@KS @KS.Container(value = {KS, KS}) public fun ks5(): kotlin.Unit
@java.lang.annotation.Repeatable(value = JR.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class JR : kotlin.Annotation {
public constructor JR()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ vararg value: JR /*kotlin.Array<out JR>*/)
public final val value: kotlin.Array<JR>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = JS.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class JS : kotlin.Annotation {
public constructor JS()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ vararg value: JS /*kotlin.Array<out JS>*/)
public final val value: kotlin.Array<JS>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = KR.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class KR : kotlin.Annotation {
public constructor KR()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ value: kotlin.Array<KR>)
public final val value: kotlin.Array<KR>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = KS.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class KS : kotlin.Annotation {
public constructor KS()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ value: kotlin.Array<KS>)
public final val value: kotlin.Array<KS>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,142 @@
// !LANGUAGE: +RepeatableAnnotations
// FULL_JDK
// FILE: JR.java
import java.lang.annotation.*;
@Repeatable(JR.Container.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface JR {
public @interface Container {
JR[] value();
}
}
// FILE: JS.java
import java.lang.annotation.*;
@Repeatable(JS.Container.class)
@Retention(RetentionPolicy.SOURCE)
public @interface JS {
public @interface Container {
JS[] value();
}
}
// FILE: KR.kt
@java.lang.annotation.Repeatable(KR.Container::class)
@Retention(AnnotationRetention.RUNTIME)
annotation class KR {
annotation class Container(val value: Array<KR>)
}
// FILE: KS.kt
@java.lang.annotation.Repeatable(KS.Container::class)
@Retention(AnnotationRetention.SOURCE)
annotation class KS {
annotation class Container(val value: Array<KS>)
}
// FILE: test.kt
// Java runtime-retained annotation
@JR
@JR.Container()
fun jr1() {}
@JR
@JR.Container()
@JR
fun jr2() {}
@JR
@JR.Container(JR())
@JR
fun jr3() {}
@JR
@JR.Container(JR())
fun jr4() {}
@JR
@JR.Container(JR(), JR())
fun jr5() {}
// Java source-retained annotation
@JS
@JS.Container()
fun js1() {}
@JS
@JS.Container()
@JS
fun js2() {}
@JS
@JS.Container(JS())
@JS
fun js3() {}
@JS
@JS.Container(JS())
fun js4() {}
@JS
@JS.Container(JS(), JS())
fun js5() {}
// Kotlin runtime-retained annotation
@KR.Container([])
@KR
fun kr1() {}
@KR.Container([])
@KR
@KR
fun kr2() {}
@KR
@KR
@KR.Container([KR()])
fun kr3() {}
@KR.Container([KR()])
@KR
fun kr4() {}
@KR
@KR.Container([KR(), KR()])
fun kr5() {}
// Kotlin source-retained annotation
@KS.Container([])
@KS
fun ks1() {}
@KS.Container([])
@KS
@KS
fun ks2() {}
@KS
@KS
@KS.Container([KS()])
fun ks3() {}
@KS.Container([KS()])
@KS
fun ks4() {}
@KS
@KS.Container([KS(), KS()])
fun ks5() {}
@@ -0,0 +1,142 @@
// !LANGUAGE: +RepeatableAnnotations
// FULL_JDK
// FILE: JR.java
import java.lang.annotation.*;
@Repeatable(JR.Container.class)
@Retention(RetentionPolicy.RUNTIME)
public @interface JR {
public @interface Container {
JR[] value();
}
}
// FILE: JS.java
import java.lang.annotation.*;
@Repeatable(JS.Container.class)
@Retention(RetentionPolicy.SOURCE)
public @interface JS {
public @interface Container {
JS[] value();
}
}
// FILE: KR.kt
@java.lang.annotation.Repeatable(KR.Container::class)
@Retention(AnnotationRetention.RUNTIME)
annotation class KR {
annotation class Container(val value: Array<KR>)
}
// FILE: KS.kt
@java.lang.annotation.Repeatable(KS.Container::class)
@Retention(AnnotationRetention.SOURCE)
annotation class KS {
annotation class Container(val value: Array<KS>)
}
// FILE: test.kt
// Java runtime-retained annotation
@JR
@JR.Container()
fun jr1() {}
@JR
@JR.Container()
<!REPEATED_ANNOTATION_WITH_CONTAINER!>@JR<!>
fun jr2() {}
@JR
@JR.Container(JR())
<!REPEATED_ANNOTATION_WITH_CONTAINER!>@JR<!>
fun jr3() {}
@JR
@JR.Container(JR())
fun jr4() {}
@JR
@JR.Container(JR(), JR())
fun jr5() {}
// Java source-retained annotation
@JS
@JS.Container()
fun js1() {}
@JS
@JS.Container()
@JS
fun js2() {}
@JS
@JS.Container(JS())
@JS
fun js3() {}
@JS
@JS.Container(JS())
fun js4() {}
@JS
@JS.Container(JS(), JS())
fun js5() {}
// Kotlin runtime-retained annotation
@KR.Container([])
@KR
fun kr1() {}
@KR.Container([])
@KR
<!REPEATED_ANNOTATION_WITH_CONTAINER!>@KR<!>
fun kr2() {}
@KR
<!REPEATED_ANNOTATION_WITH_CONTAINER!>@KR<!>
@KR.Container([KR()])
fun kr3() {}
@KR.Container([KR()])
@KR
fun kr4() {}
@KR
@KR.Container([KR(), KR()])
fun kr5() {}
// Kotlin source-retained annotation
@KS.Container([])
@KS
fun ks1() {}
@KS.Container([])
@KS
@KS
fun ks2() {}
@KS
@KS
@KS.Container([KS()])
fun ks3() {}
@KS.Container([KS()])
@KS
fun ks4() {}
@KS
@KS.Container([KS(), KS()])
fun ks5() {}
@@ -0,0 +1,83 @@
package
@JR @JR.Container(value = {}) public fun jr1(): kotlin.Unit
@JR @JR.Container(value = {}) @JR public fun jr2(): kotlin.Unit
@JR @JR.Container(value = {JR}) @JR public fun jr3(): kotlin.Unit
@JR @JR.Container(value = {JR}) public fun jr4(): kotlin.Unit
@JR @JR.Container(value = {JR, JR}) public fun jr5(): kotlin.Unit
@JS @JS.Container(value = {}) public fun js1(): kotlin.Unit
@JS @JS.Container(value = {}) @JS public fun js2(): kotlin.Unit
@JS @JS.Container(value = {JS}) @JS public fun js3(): kotlin.Unit
@JS @JS.Container(value = {JS}) public fun js4(): kotlin.Unit
@JS @JS.Container(value = {JS, JS}) public fun js5(): kotlin.Unit
@KR.Container(value = {}) @KR public fun kr1(): kotlin.Unit
@KR.Container(value = {}) @KR @KR public fun kr2(): kotlin.Unit
@KR @KR @KR.Container(value = {KR}) public fun kr3(): kotlin.Unit
@KR.Container(value = {KR}) @KR public fun kr4(): kotlin.Unit
@KR @KR.Container(value = {KR, KR}) public fun kr5(): kotlin.Unit
@KS.Container(value = {}) @KS public fun ks1(): kotlin.Unit
@KS.Container(value = {}) @KS @KS public fun ks2(): kotlin.Unit
@KS @KS @KS.Container(value = {KS}) public fun ks3(): kotlin.Unit
@KS.Container(value = {KS}) @KS public fun ks4(): kotlin.Unit
@KS @KS.Container(value = {KS, KS}) public fun ks5(): kotlin.Unit
@java.lang.annotation.Repeatable(value = JR.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class JR : kotlin.Annotation {
public constructor JR()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ vararg value: JR /*kotlin.Array<out JR>*/)
public final val value: kotlin.Array<JR>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = JS.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class JS : kotlin.Annotation {
public constructor JS()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ vararg value: JS /*kotlin.Array<out JS>*/)
public final val value: kotlin.Array<JS>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = KR.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class KR : kotlin.Annotation {
public constructor KR()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ value: kotlin.Array<KR>)
public final val value: kotlin.Array<KR>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@java.lang.annotation.Repeatable(value = KS.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class KS : kotlin.Annotation {
public constructor KS()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public final annotation class Container : kotlin.Annotation {
public constructor Container(/*0*/ value: kotlin.Array<KS>)
public final val value: kotlin.Array<KS>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}