getElementAnnotations

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

@Serializable
@SomeSerialAnnotation
class Nested(...)

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

outerDescriptor.getElementAnnotations(0) // Returns [@AnotherSerialAnnotation]
outerDescriptor.getElementDescriptor(0).annotations // Returns [@SomeSerialAnnotation]

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).