Skip to content

71 Annotation targets ​

Label implements TypeTarget, so it may mark a type declaration. SourceRetention keeps this annotation's role in compilation without making it runtime-reflectable.

norm
import std.annotation.TypeTarget
import std.annotation.SourceRetention

annotation Label implements TypeTarget, SourceRetention {
  String text
}

@Label(text: "task")
class Task { String title }

main() {
  printLine(Task(title: "Learn Norm").title)
}

Expected output:

text
Learn Norm

Try it: Move @Label onto main() and inspect the target diagnostic.

Precise rules: Reference.

Norm 0.25