getElementAnnotations

Returns serial annotations of the child element at the given index. This method differs from getElementDescriptor(index).annotations by reporting only element-specific annotations:

@Serializable
@OnClassSerialAnnotation
class Nested(...)

@Serializable
class Outer(@OnPropertySerialAnnotation val nested: Nested)

val outerDescriptor = Outer.serializer().descriptor

outerDescriptor.getElementAnnotations(0) // Returns [@OnPropertySerialAnnotation]
outerDescriptor.getElementDescriptor(0).annotations // Returns [@OnClassSerialAnnotation]

Only annotations marked with SerialInfo are added to the resulting list.

Throws

for an illegal index values.

if the current descriptor does not support children elements (e.g. is a primitive).