diff --git a/kotlin-native/runtime/src/main/kotlin/kotlin/annotation/Annotations.kt b/kotlin-native/runtime/src/main/kotlin/kotlin/annotation/Annotations.kt index 4091a425c72..97e659e6fba 100644 --- a/kotlin-native/runtime/src/main/kotlin/kotlin/annotation/Annotations.kt +++ b/kotlin-native/runtime/src/main/kotlin/kotlin/annotation/Annotations.kt @@ -15,7 +15,7 @@ public enum class AnnotationTarget { CLASS, /** Annotation class only */ ANNOTATION_CLASS, - /** Generic type parameter (unsupported yet) */ + /** Generic type parameter */ TYPE_PARAMETER, /** Property */ PROPERTY, diff --git a/native/native.tests/testData/klibContents/annotations.kt b/native/native.tests/testData/klibContents/annotations.kt index e126ff727c4..2cdfa42c663 100644 --- a/native/native.tests/testData/klibContents/annotations.kt +++ b/native/native.tests/testData/klibContents/annotations.kt @@ -1,4 +1,5 @@ package test + annotation class AnnoClass annotation class AnnoConstructor annotation class AnnoConstructorParameter @@ -14,6 +15,14 @@ annotation class AnnoFunction annotation class AnnoFunctionParam annotation class AnnoFunctionExtensionReceiver annotation class AnnoPropertyExtensionReceiver + +@Target(AnnotationTarget.TYPE_PARAMETER) +annotation class AnnoFunctionTypeParameter +@Target(AnnotationTarget.TYPE_PARAMETER) +annotation class AnnoClassTypeParameter +@Target(AnnotationTarget.TYPE) +annotation class AnnoClassUsageTypeParameter + @AnnoClass class Foo @AnnoConstructor constructor(@AnnoConstructorParameter i: Int) { @AnnoProperty @@ -36,3 +45,6 @@ class Foo @AnnoConstructor constructor(@AnnoConstructorParameter i: Int) { fun @receiver:AnnoFunctionExtensionReceiver Foo.extfun(@AnnoFunctionParam x: Int) {} @AnnoPropertyExtensionReceiver val Foo.extProp get() = this.prop + +fun <@AnnoFunctionTypeParameter T> f(x : B<@AnnoClassUsageTypeParameter Int>) {} +class B<@AnnoClassTypeParameter T> \ No newline at end of file diff --git a/native/native.tests/testData/klibContents/annotations.txt b/native/native.tests/testData/klibContents/annotations.txt index 75d33179c06..6a641b39d87 100644 --- a/native/native.tests/testData/klibContents/annotations.txt +++ b/native/native.tests/testData/klibContents/annotations.txt @@ -1,11 +1,14 @@ annotation class AnnoBackingField constructor() : Annotation annotation class AnnoClass constructor() : Annotation + @Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) annotation class AnnoClassTypeParameter constructor() : Annotation + @Target(allowedTargets = {AnnotationTarget.TYPE}) annotation class AnnoClassUsageTypeParameter constructor() : Annotation annotation class AnnoConstructor constructor() : Annotation annotation class AnnoConstructorParameter constructor() : Annotation annotation class AnnoDelegatedField constructor() : Annotation annotation class AnnoFunction constructor() : Annotation annotation class AnnoFunctionExtensionReceiver constructor() : Annotation annotation class AnnoFunctionParam constructor() : Annotation + @Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) annotation class AnnoFunctionTypeParameter constructor() : Annotation annotation class AnnoGetter constructor() : Annotation annotation class AnnoProperty constructor() : Annotation annotation class AnnoPropertyExtensionReceiver constructor() : Annotation @@ -13,6 +16,7 @@ annotation class AnnoSetParam2 constructor() : Annotation annotation class AnnoSetter constructor() : Annotation annotation class AnnoSetter2 constructor() : Annotation + class B<@AnnoClassTypeParameter T> constructor() @AnnoClass class Foo @AnnoConstructor constructor(@AnnoConstructorParameter i: Int) { @delegate:AnnoDelegatedField val immutableProp: Int var mutableProp: Int @@ -22,4 +26,5 @@ @AnnoSetter set } @AnnoPropertyExtensionReceiver val Foo.extProp: Int - @AnnoFunction fun @receiver:AnnoFunctionExtensionReceiver Foo.extfun(@AnnoFunctionParam x: Int) \ No newline at end of file + @AnnoFunction fun @receiver:AnnoFunctionExtensionReceiver Foo.extfun(@AnnoFunctionParam x: Int) + fun <@AnnoFunctionTypeParameter T> f(x: B<@AnnoClassUsageTypeParameter Int>) \ No newline at end of file