[FIR] Fix serializing annotation metadata on setters value parameters
This commit is contained in:
+16
-7
@@ -199,8 +199,10 @@ class FirElementSerializer private constructor(
|
|||||||
|
|
||||||
private fun FirPropertyAccessor.nonSourceAnnotations(session: FirSession, property: FirProperty): List<FirAnnotationCall> =
|
private fun FirPropertyAccessor.nonSourceAnnotations(session: FirSession, property: FirProperty): List<FirAnnotationCall> =
|
||||||
(this as FirAnnotationContainer).nonSourceAnnotations(session) + property.nonSourceAnnotations(session).filter {
|
(this as FirAnnotationContainer).nonSourceAnnotations(session) + property.nonSourceAnnotations(session).filter {
|
||||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER && isGetter ||
|
val useSiteTarget = it.useSiteTarget
|
||||||
it.useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER && isSetter
|
useSiteTarget == AnnotationUseSiteTarget.PROPERTY_GETTER && isGetter ||
|
||||||
|
useSiteTarget == AnnotationUseSiteTarget.PROPERTY_SETTER && isSetter ||
|
||||||
|
useSiteTarget == AnnotationUseSiteTarget.SETTER_PARAMETER && isSetter
|
||||||
}
|
}
|
||||||
|
|
||||||
fun propertyProto(property: FirProperty): ProtoBuf.Property.Builder? {
|
fun propertyProto(property: FirProperty): ProtoBuf.Property.Builder? {
|
||||||
@@ -241,13 +243,15 @@ class FirElementSerializer private constructor(
|
|||||||
builder.setterFlags = accessorFlags
|
builder.setterFlags = accessorFlags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val nonSourceAnnotations = setter.nonSourceAnnotations(session, property)
|
||||||
if (setter !is FirDefaultPropertyAccessor ||
|
if (setter !is FirDefaultPropertyAccessor ||
|
||||||
setter.nonSourceAnnotations(session, property).isNotEmpty() ||
|
nonSourceAnnotations.isNotEmpty() ||
|
||||||
setter.visibility != property.visibility
|
setter.visibility != property.visibility
|
||||||
) {
|
) {
|
||||||
val setterLocal = local.createChildSerializer(setter)
|
val setterLocal = local.createChildSerializer(setter)
|
||||||
for (valueParameterDescriptor in setter.valueParameters) {
|
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
|
return builder
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun valueParameterProto(parameter: FirValueParameter): ProtoBuf.ValueParameter.Builder {
|
private fun valueParameterProto(
|
||||||
|
parameter: FirValueParameter,
|
||||||
|
additionalAnnotations: List<FirAnnotationCall> = emptyList()
|
||||||
|
): ProtoBuf.ValueParameter.Builder {
|
||||||
val builder = ProtoBuf.ValueParameter.newBuilder()
|
val builder = ProtoBuf.ValueParameter.newBuilder()
|
||||||
|
|
||||||
val declaresDefaultValue = parameter.defaultValue != null // TODO: || parameter.isActualParameterWithAnyExpectedDefault
|
val declaresDefaultValue = parameter.defaultValue != null // TODO: || parameter.isActualParameterWithAnyExpectedDefault
|
||||||
|
|
||||||
val flags = Flags.getValueParameterFlags(
|
val flags = Flags.getValueParameterFlags(
|
||||||
parameter.nonSourceAnnotations(session).isNotEmpty(), declaresDefaultValue,
|
additionalAnnotations.isNotEmpty() || parameter.nonSourceAnnotations(session).isNotEmpty(),
|
||||||
parameter.isCrossinline, parameter.isNoinline
|
declaresDefaultValue,
|
||||||
|
parameter.isCrossinline,
|
||||||
|
parameter.isNoinline
|
||||||
)
|
)
|
||||||
if (flags != builder.flags) {
|
if (flags != builder.flags) {
|
||||||
builder.flags = flags
|
builder.flags = flags
|
||||||
|
|||||||
+1
-2
@@ -1,4 +1,3 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
|
||||||
// WITH_REFLECT
|
// WITH_REFLECT
|
||||||
// TARGET_BACKEND: JVM
|
// TARGET_BACKEND: JVM
|
||||||
|
|
||||||
@@ -160,4 +159,4 @@ fun box(): String {
|
|||||||
Statics().test()
|
Statics().test()
|
||||||
Delegate().test()
|
Delegate().test()
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user