[FIR] KT-52157: Fix missing type parameter annotations

This commit is contained in:
Nikolay Lunyak
2022-10-06 14:13:14 +03:00
committed by teamcity
parent 5347c3c7cc
commit dd861515ad
15 changed files with 72 additions and 2 deletions
@@ -56,6 +56,11 @@ public class FirLoadCompiledKotlinGenerated extends AbstractFirLoadCompiledKotli
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -0,0 +1,9 @@
public final class Convert<@R|test/Schema|() T, C> : R|kotlin/Any| {
public constructor<@R|test/Schema|() T, C>(): R|test/Convert<T, C>|
}
@R|kotlin/annotation/Target|(allowedTargets = <implicitArrayOf>(R|kotlin/annotation/AnnotationTarget.TYPE_PARAMETER|())) public final annotation class Schema : R|kotlin/Annotation| {
public constructor(): R|test/Schema|
}
@@ -4,7 +4,7 @@
}
public final class SimpleTypeParameterAnnotation : R|kotlin/Any| {
public final fun <T> foo(x: R|T|): R|kotlin/Unit|
public final fun <@R|test/A|() T> foo(x: R|T|): R|kotlin/Unit|
public constructor(): R|test/SimpleTypeParameterAnnotation|
@@ -10,7 +10,7 @@
}
public final class SimpleTypeParameterAnnotation : R|kotlin/Any| {
public final fun <T> foo(x: R|T|): R|kotlin/Unit|
public final fun <@R|test/A|(x = String(a), y = Double(1.0)) T> foo(x: R|T|): R|kotlin/Unit|
public constructor(): R|test/SimpleTypeParameterAnnotation|
@@ -24,4 +24,9 @@ class KlibBasedAnnotationDeserializer(
val annotations = typeProto.getExtension(KlibMetadataProtoBuf.typeAnnotation).orEmpty()
return annotations.map { deserializeAnnotation(it, nameResolver) }
}
override fun loadTypeParameterAnnotations(typeParameterProto: ProtoBuf.TypeParameter, nameResolver: NameResolver): List<FirAnnotation> {
val annotations = typeParameterProto.getExtension(KlibMetadataProtoBuf.typeParameterAnnotation).orEmpty()
return annotations.map { deserializeAnnotation(it, nameResolver) }
}
}
@@ -172,6 +172,9 @@ abstract class AbstractAnnotationDeserializer(
abstract fun loadTypeAnnotations(typeProto: ProtoBuf.Type, nameResolver: NameResolver): List<FirAnnotation>
open fun loadTypeParameterAnnotations(typeParameterProto: ProtoBuf.TypeParameter, nameResolver: NameResolver) =
emptyList<FirAnnotation>()
fun deserializeAnnotation(
proto: ProtoBuf.Annotation,
nameResolver: NameResolver,
@@ -76,6 +76,7 @@ class FirTypeDeserializer(
this.containingDeclarationSymbol = containingSymbol ?: error("Top-level type parameter ???")
variance = proto.variance.convertVariance()
isReified = proto.reified
annotations += annotationDeserializer.loadTypeParameterAnnotations(proto, nameResolver)
}
result[proto.id] = symbol
}
@@ -52,6 +52,11 @@ class JvmBinaryAnnotationDeserializer(
return annotations.map { deserializeAnnotation(it, nameResolver) }
}
override fun loadTypeParameterAnnotations(typeParameterProto: ProtoBuf.TypeParameter, nameResolver: NameResolver): List<FirAnnotation> {
val annotations = typeParameterProto.getExtension(JvmProtoBuf.typeParameterAnnotation).orEmpty()
return annotations.map { deserializeAnnotation(it, nameResolver) }
}
override fun loadConstructorAnnotations(
containerSource: DeserializedContainerSource?,
constructorProto: ProtoBuf.Constructor,
@@ -0,0 +1,8 @@
package test
// See: KT-52157
@Target(AnnotationTarget.TYPE_PARAMETER)
public annotation class Schema
class Convert<@Schema T, C>()
@@ -0,0 +1,9 @@
package test
public final class Convert</*0*/ @test.Schema T, /*1*/ C> {
/*primary*/ public constructor Convert</*0*/ @test.Schema T, /*1*/ C>()
}
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.TYPE_PARAMETER}) public final annotation class Schema : kotlin.Annotation {
/*primary*/ public constructor Schema()
}
@@ -1739,6 +1739,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -56,6 +56,11 @@ public class LoadKotlinWithTypeTableTestGenerated extends AbstractLoadKotlinWith
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -1740,6 +1740,11 @@ public class IrLoadJavaTestGenerated extends AbstractIrLoadJavaTest {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -1739,6 +1739,11 @@ public class LoadJavaUsingJavacTestGenerated extends AbstractLoadJavaUsingJavacT
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");
@@ -58,6 +58,11 @@ public class JvmRuntimeDescriptorLoaderTestGenerated extends AbstractJvmRuntimeD
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationInArray.kt");
}
@TestMetadata("AnnotationOnTypeParameter.kt")
public void testAnnotationOnTypeParameter() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/AnnotationOnTypeParameter.kt");
}
@TestMetadata("ClassLiteralArguments.kt")
public void testClassLiteralArguments() throws Exception {
runTest("compiler/testData/loadJava/compiledKotlin/annotations/ClassLiteralArguments.kt");