diff --git a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirAnnotationSerializer.kt b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirAnnotationSerializer.kt index bb590551a9d..190908db954 100644 --- a/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirAnnotationSerializer.kt +++ b/compiler/fir/fir-serialization/src/org/jetbrains/kotlin/fir/serialization/FirAnnotationSerializer.kt @@ -7,11 +7,13 @@ package org.jetbrains.kotlin.fir.serialization import org.jetbrains.kotlin.fir.FirSession import org.jetbrains.kotlin.fir.expressions.* +import org.jetbrains.kotlin.fir.expressions.impl.FirResolvedArgumentList import org.jetbrains.kotlin.fir.resolve.toSymbol import org.jetbrains.kotlin.fir.serialization.constant.ConstantValue import org.jetbrains.kotlin.fir.serialization.constant.toConstantValue import org.jetbrains.kotlin.fir.types.* import org.jetbrains.kotlin.metadata.ProtoBuf +import org.jetbrains.kotlin.name.Name class FirAnnotationSerializer(private val session: FirSession, internal val stringTable: FirElementAwareStringTable) { fun serializeAnnotation(annotation: FirAnnotationCall): ProtoBuf.Annotation = ProtoBuf.Annotation.newBuilder().apply { @@ -20,13 +22,24 @@ class FirAnnotationSerializer(private val session: FirSession, internal val stri id = stringTable.getFqNameIndex(annotationClass) - for (argumentExpression in annotation.argumentList.arguments) { - if (argumentExpression !is FirNamedArgumentExpression) continue + fun addArgument(argumentExpression: FirExpression, parameterName: Name) { val argument = ProtoBuf.Annotation.Argument.newBuilder() - argument.nameId = stringTable.getStringIndex(argumentExpression.name.asString()) - argument.setValue(valueProto(argumentExpression.toConstantValue() ?: continue)) + argument.nameId = stringTable.getStringIndex(parameterName.asString()) + argument.setValue(valueProto(argumentExpression.toConstantValue() ?: return)) addArgument(argument) } + + val argumentList = annotation.argumentList + if (argumentList is FirResolvedArgumentList) { + for ((argumentExpression, parameter) in argumentList.mapping) { + addArgument(argumentExpression, parameter.name) + } + } else { + for (argumentExpression in argumentList.arguments) { + if (argumentExpression !is FirNamedArgumentExpression) continue + addArgument(argumentExpression, argumentExpression.name) + } + } }.build() internal fun valueProto(constant: ConstantValue<*>): ProtoBuf.Annotation.Argument.Value.Builder = diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/classTypeParameterBound.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/classTypeParameterBound.kt index cb4599b2215..2c1427119ad 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/classTypeParameterBound.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/classTypeParameterBound.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // EMIT_JVM_TYPE_ANNOTATIONS // JVM_TARGET: 1.8 diff --git a/compiler/testData/codegen/box/annotations/typeAnnotations/functionTypeParameterBound.kt b/compiler/testData/codegen/box/annotations/typeAnnotations/functionTypeParameterBound.kt index f2cf80986c7..9f17946ead7 100644 --- a/compiler/testData/codegen/box/annotations/typeAnnotations/functionTypeParameterBound.kt +++ b/compiler/testData/codegen/box/annotations/typeAnnotations/functionTypeParameterBound.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // TARGET_BACKEND: JVM // EMIT_JVM_TYPE_ANNOTATIONS // JVM_TARGET: 1.8