SE-0385: Custom Reflection Metadata

The call is invoked through the reflection API. From the proposal:

Instances of metadata types are initialized in the Reflection query to gather the metadata.

This is done in the implementation of Attribute.allInstances. The compiler-synthesized call is emitted into a "generator function" with a record of that generator function in the reflection metadata. The implementation of Attribute.allInstances gathers the metadata and initializes all of the resulting instances.

The only way to retrieve metadata instances is through the reflection query, which is accessible anywhere that imports the library containing the reflection API. In the proposal, that's a dedicated Reflection library, as described in-detail in this pitch.

1 Like