Remove mapping of java.Repeatable to kotlin.Repeatable in JavaAnnotationMapper

The main motivation for this change is that
java.lang.annotation.Repeatable has a parameter for the container
annotation, which is lost during conversion to
kotlin.annotation.Repeatable. To support j.l.a.Repeatable in backend
properly, it's absolutely necessary to be able to load the container
annotation for any repeatable annotation class, so the original
j.l.a.Repeatable needs to be stored in the descriptor and accessible
from the backend.

Instead of mapping j.l.a.Repeatable -> k.a.Repeatable, add a frontend
service PlatformAnnotationFeaturesSupport that will determine if an
annotation is repeatable "according to the platform rules", which for
JVM means that it's annotated with j.l.a.Repeatable.

Some effects of this change include:
- Usages of j.l.a.Repeatable are no longer reported as "deprecated", the
  corresponding test is deleted
- Usages of repeatable annotations declared in Java with non-SOURCE
  retention with LV 1.5 and earlier will now result in a slightly
  different error (REPEATED_ANNOTATION instead of
  NON_SOURCE_REPEATED_ANNOTATION)

 #KT-12794
This commit is contained in:
Alexander Udalov
2021-07-20 18:08:10 +02:00
parent ebf837c135
commit f723389565
15 changed files with 64 additions and 90 deletions
@@ -1,11 +0,0 @@
// FULL_JDK
import java.lang.annotation.Repeatable
@java.lang.annotation.Repeatable(Annotations::class) annotation class RepAnn
@Repeatable(OtherAnnotations::class) annotation class OtherAnn
annotation class Annotations(vararg val value: RepAnn)
annotation class OtherAnnotations(vararg val value: OtherAnn)
@@ -1,11 +0,0 @@
// FULL_JDK
import java.lang.annotation.Repeatable
<!DEPRECATED_JAVA_ANNOTATION!>@java.lang.annotation.Repeatable(Annotations::class)<!> annotation class RepAnn
<!DEPRECATED_JAVA_ANNOTATION!>@Repeatable(OtherAnnotations::class)<!> annotation class OtherAnn
annotation class Annotations(vararg val value: RepAnn)
annotation class OtherAnnotations(vararg val value: OtherAnn)
@@ -1,31 +0,0 @@
package
public final annotation class Annotations : kotlin.Annotation {
public constructor Annotations(/*0*/ vararg value: RepAnn /*kotlin.Array<out RepAnn>*/)
public final val value: kotlin.Array<out RepAnn>
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 = OtherAnnotations::class) public final annotation class OtherAnn : kotlin.Annotation {
public constructor OtherAnn()
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 OtherAnnotations : kotlin.Annotation {
public constructor OtherAnnotations(/*0*/ vararg value: OtherAnn /*kotlin.Array<out OtherAnn>*/)
public final val value: kotlin.Array<out OtherAnn>
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 = Annotations::class) public final annotation class RepAnn : kotlin.Annotation {
public constructor RepAnn()
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
}
@@ -37,10 +37,10 @@ public @interface Source {
// FILE: usage.kt
@Runtime <!NON_SOURCE_REPEATED_ANNOTATION!>@Runtime<!>
@Runtime <!REPEATED_ANNOTATION!>@Runtime<!>
class UseRuntime
@Clazz <!NON_SOURCE_REPEATED_ANNOTATION!>@Clazz<!>
@Clazz <!REPEATED_ANNOTATION!>@Clazz<!>
class UseClazz
@Source @Source
@@ -1,6 +1,6 @@
package
@kotlin.annotation.Repeatable @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class Clazz : kotlin.Annotation {
@java.lang.annotation.Repeatable(value = Clazz.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.BINARY) public final annotation class Clazz : kotlin.Annotation {
public constructor Clazz()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -15,7 +15,7 @@ package
}
}
@kotlin.annotation.Repeatable @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Runtime : kotlin.Annotation {
@java.lang.annotation.Repeatable(value = Runtime.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.RUNTIME) public final annotation class Runtime : kotlin.Annotation {
public constructor Runtime()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -30,7 +30,7 @@ package
}
}
@kotlin.annotation.Repeatable @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Source : kotlin.Annotation {
@java.lang.annotation.Repeatable(value = Source.Container::class) @kotlin.annotation.Retention(value = AnnotationRetention.SOURCE) public final annotation class Source : kotlin.Annotation {
public constructor Source()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int