Instantiation of annotations for JVM IR with the corresponding feature flag

Seperate checker for platforms that do not support this language feature yet

Synthetic implementations of annotations are generated on-demand with proper 
equals, hashCode, and annotationType methods

#KT-47699 Fixed
This commit is contained in:
Leonid Startsev
2021-07-21 10:23:51 +00:00
committed by Space
parent 4bc521249b
commit ce0a3a57df
59 changed files with 1589 additions and 64 deletions
@@ -0,0 +1,11 @@
// WITH_RUNTIME
// IGNORE_BACKEND: JVM
// !LANGUAGE: +InstantiationOfAnnotationClasses
annotation class Foo(val int: Int)
annotation class Bar
fun box() {
val foo = Foo(42)
}
@@ -0,0 +1,32 @@
@kotlin.Metadata
public synthetic final class AnnotationCtorCallGenerateSyntheticKt$annotationImpl$Foo$0 {
// source: 'annotationCtorCallGenerateSynthetic.kt'
private synthetic final field int: int
public method <init>(p0: int): void
public synthetic final method annotationType(): java.lang.Class
public final method equals(@org.jetbrains.annotations.Nullable p0: java.lang.Object): boolean
public final method hashCode(): int
public synthetic final method int(): int
public final @org.jetbrains.annotations.NotNull method toString(): java.lang.String
public synthetic inner class AnnotationCtorCallGenerateSyntheticKt$annotationImpl$Foo$0
}
@kotlin.Metadata
public final class AnnotationCtorCallGenerateSyntheticKt {
// source: 'annotationCtorCallGenerateSynthetic.kt'
public final static method box(): void
public synthetic inner class AnnotationCtorCallGenerateSyntheticKt$annotationImpl$Foo$0
}
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Bar {
// source: 'annotationCtorCallGenerateSynthetic.kt'
}
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Foo {
// source: 'annotationCtorCallGenerateSynthetic.kt'
public abstract method int(): int
}
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// !LANGUAGE: +InstantiationOfAnnotationClasses
annotation class Foo(val bar: Bar)
annotation class Bar
@Foo(Bar())
fun box() {
}
@@ -0,0 +1,18 @@
@kotlin.Metadata
public final class AnnotationCtorCallNoSyntheticKt {
// source: 'annotationCtorCallNoSynthetic.kt'
public final static @Foo method box(): void
}
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Bar {
// source: 'annotationCtorCallNoSynthetic.kt'
}
@java.lang.annotation.Retention
@kotlin.Metadata
public annotation class Foo {
// source: 'annotationCtorCallNoSynthetic.kt'
public abstract method bar(): Bar
}