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 5ca68eaa6c9..7dda86719c8 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 @@ -199,8 +199,10 @@ class FirElementSerializer private constructor( private fun FirPropertyAccessor.nonSourceAnnotations(session: FirSession, property: FirProperty): List = (this as FirAnnotationContainer).nonSourceAnnotations(session) + property.nonSourceAnnotations(session).filter { - it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER && isGetter || - it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER && isSetter + val useSiteTarget = it.useSiteTarget + useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER && isGetter || + useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER && isSetter || + useSiteTarget == AnnotationUseSiteTarget.SETTER_PARAMETER && isSetter } fun propertyProto(property: FirProperty): ProtoBuf.Property.Builder? { @@ -241,13 +243,15 @@ class FirElementSerializer private constructor( builder.setterFlags = accessorFlags } + val nonSourceAnnotations = setter.nonSourceAnnotations(session, property) if (setter !is FirDefaultPropertyAccessor || - setter.nonSourceAnnotations(session, property).isNotEmpty() || + nonSourceAnnotations.isNotEmpty() || setter.visibility != property.visibility ) { val setterLocal = local.createChildSerializer(setter) for (valueParameterDescriptor in setter.valueParameters) { - builder.setSetterValueParameter(setterLocal.valueParameterProto(valueParameterDescriptor)) + val annotations = nonSourceAnnotations.filter { it.useSiteTarget == AnnotationUseSiteTarget.SETTER_PARAMETER } + builder.setSetterValueParameter(setterLocal.valueParameterProto(valueParameterDescriptor, annotations)) } } } @@ -480,14 +484,19 @@ class FirElementSerializer private constructor( return builder } - private fun valueParameterProto(parameter: FirValueParameter): ProtoBuf.ValueParameter.Builder { + private fun valueParameterProto( + parameter: FirValueParameter, + additionalAnnotations: List = emptyList() + ): ProtoBuf.ValueParameter.Builder { val builder = ProtoBuf.ValueParameter.newBuilder() val declaresDefaultValue = parameter.defaultValue != null // TODO: || parameter.isActualParameterWithAnyExpectedDefault val flags = Flags.getValueParameterFlags( - parameter.nonSourceAnnotations(session).isNotEmpty(), declaresDefaultValue, - parameter.isCrossinline, parameter.isNoinline + additionalAnnotations.isNotEmpty() || parameter.nonSourceAnnotations(session).isNotEmpty(), + declaresDefaultValue, + parameter.isCrossinline, + parameter.isNoinline ) if (flags != builder.flags) { builder.flags = flags diff --git a/compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt b/compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt index 4fb0a6b81b9..f0ba61f0872 100644 --- a/compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt +++ b/compiler/testData/codegen/box/annotations/annotationsOnNonExistentAccessors.kt @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_FIR: JVM_IR // WITH_REFLECT // TARGET_BACKEND: JVM @@ -160,4 +159,4 @@ fun box(): String { Statics().test() Delegate().test() return "OK" -} \ No newline at end of file +}