From d89680b30d10459f1a2e34a19a711dc2a004a66b Mon Sep 17 00:00:00 2001 From: Mads Ager Date: Tue, 30 Nov 2021 14:04:12 +0100 Subject: [PATCH] [FIR] Serialize annotations for type parameters properly --- .../kotlin/fir/serialization/FirElementSerializer.kt | 9 ++++----- .../reflection/annotations/onTypes/differentPositions.kt | 2 -- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt index f354043633b..61774f3c0ff 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirElementSerializer.kt @@ -610,10 +610,6 @@ class FirElementSerializer private constructor( private fun typeProto(typeRef: FirTypeRef, toSuper: Boolean = false): ProtoBuf.Type.Builder { val coneType = typeRef.coneType return typeProto(coneType, toSuper, correspondingTypeRef = typeRef).also { typeProto -> - for (annotation in coneType.attributes.customAnnotations) { - extension.serializeTypeAnnotation(annotation, typeProto) - } - val compilerAttributes = mutableListOf>() val extensionAttributes = mutableListOf>() for (attribute in coneType.attributes) { @@ -654,7 +650,6 @@ class FirElementSerializer private constructor( isDefinitelyNotNullType: Boolean = false, ): ProtoBuf.Type.Builder { val builder = ProtoBuf.Type.newBuilder() - when (type) { is ConeDefinitelyNotNullType -> return typeProto(type.original, toSuper, correspondingTypeRef, isDefinitelyNotNullType = true) is ConeKotlinErrorType -> { @@ -726,6 +721,10 @@ class FirElementSerializer private constructor( builder.nullable = type.isMarkedNullable } + for (annotation in type.attributes.customAnnotations) { + extension.serializeTypeAnnotation(annotation, builder) + } + // TODO: abbreviated type // val abbreviation = type.getAbbreviatedType()?.abbreviation // if (abbreviation != null) { diff --git a/compiler/testData/codegen/box/reflection/annotations/onTypes/differentPositions.kt b/compiler/testData/codegen/box/reflection/annotations/onTypes/differentPositions.kt index 260325a66e8..177763f9403 100644 --- a/compiler/testData/codegen/box/reflection/annotations/onTypes/differentPositions.kt +++ b/compiler/testData/codegen/box/reflection/annotations/onTypes/differentPositions.kt @@ -1,5 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR -// FIR status: No annotations found on type argument // TARGET_BACKEND: JVM // WITH_REFLECT