getElementAnnotations

abstract fun getElementAnnotations(index: Int): List<Annotation>

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

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