What is an annotation?
An annotation is a top level function that returns a subtype of ConstrainedAnnotation.
There are 2 interfaces which satisfy ConstrainedAnnotation directly:
Let's see the type hierarchy of ConstrainedAnnotation to get a better picture.
So what you might have thought to be reserved keywords (shared, formal, actual, ...) are in fact annotations used by the compiler. Let's see how the DocAnnotation is implemented.
An annotation is a top level function that returns a subtype of ConstrainedAnnotation.
There are 2 interfaces which satisfy ConstrainedAnnotation directly:
- OptionalAnnotation: An annotation that may occur at most once at a single program element and only on certain program elements.
- SequencedAnnotation: An annotation that may occur multiple times at a single program element, and only on certain program elements.
Let's see the type hierarchy of ConstrainedAnnotation to get a better picture.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"The annotation class for the [[doc]] annotation." | |
shared final annotation class DocAnnotation( | |
"Documentation, in Markdown syntax, about the annotated element" | |
shared String description) | |
satisfies OptionalAnnotation<DocAnnotation, Annotated> {} | |
"Annotation to specify API documentation of a program | |
element." | |
shared annotation DocAnnotation doc( | |
"Documentation, in Markdown syntax, about the annotated element" | |
String description) => DocAnnotation(description); |
No comments:
Post a Comment