package annotation
- Alphabetic
- Public
- All
Type Members
-
trait
AnnotationAggregate extends Annotation with StaticAnnotation
Base trait for annotations which aggregate multiple other annotations.
Base trait for annotations which aggregate multiple other annotations. This way annotation aggregates work like "annotation functions" - they are annotations that yield more annotations.
In order to specify aggregated annotations, the class that extends
AnnotationAggregate
must redefine theImplied
dummy type member and apply the aggregated annotations on it. Macro engines used inGenCodec
materialization and RPC framework will automatically pick up these annotations.import com.avsystem.commons.serialization._ class mongoId extends AnnotationAggregate { @name("_id") @outOfOrder type Implied } case class SomeMongoEntity(@mongoId id: String, data: String)
In the above example, applying
@mongoId
annotation on theid
field has the same effect as if annotations@name("_id") @outOfOrder
were applied directly on that field.NOTE: thanks to the fact that aggregated annotations are applied on a type member you can pass the arguments of original annotation to aggregated annotations, e.g.
class rpcNameAndDescription(name: String, description: String) extends AnnotationAggregate { @rpcName(name) // passing `name` to aggregated annotation type Implied }
-
trait
NotInheritedFromSealedTypes extends Annotation with StaticAnnotation
Marker trait for annotations which don't want to be inherited by subtypes of a sealed trait or class that has this annotation applied.
Marker trait for annotations which don't want to be inherited by subtypes of a sealed trait or class that has this annotation applied. Intended for annotations that should apply only to the sealed trait itself.
-
class
atLeast extends Annotation with StaticAnnotation
When applied on varargs parameter, indicates that at least some number of parameters is required.
When applied on varargs parameter, indicates that at least some number of parameters is required. This is later checked by the static analyzer.
WARNING: implementation of method which takes a varargs parameter may NOT assume that given number of arguments will always be passed, because it's still possible to pass aSeq
where varargs parameter is required using the: _*
ascription, e.g.varargsMethod(List(): _*)
and that is not checked by the static analyzer.
-
class
bincompat extends Annotation
Marks symbols which exist only for binary compatibility with previous versions.
Marks symbols which exist only for binary compatibility with previous versions. These symbols should never be used directly. This is checked by
commons-analyzer
plugin. Additionally, it's recommended to make these symbols package private so that they cannot be used directly from Scala code but remain public in bytecode. -
class
defaultsToName extends Annotation with StaticAnnotation
Meta annotation that may be used on
String
constructor parameter of an annotation.Meta annotation that may be used on
String
constructor parameter of an annotation. This constructor parameter must take a defaultnull
value. defaultsToName makes annotation processing macro engines insert the name of annotated symbol instead ofnull
.class SomeMethodAnnotation(@defaultsToName val name: String = null) @SomeMethodAnnotation def someMethod: String
Now, when some macro engine has to inspect
SomeMethodAnnotation
ofsomeMethod
, it will automatically insert the string "someMethod" as the argument ofSomeMethodAnnotation
.
Example: -
class
explicitGenerics extends Annotation with StaticAnnotation
When applied on generic method, requires that all the type parameters are given explicitly (cannot be inferred by the compiler).
When applied on generic method, requires that all the type parameters are given explicitly (cannot be inferred by the compiler). This is meant primarily for methods whose generics cannot be inferred from method arguments. Requiring that the programmer specifies them explicitly is a protection against the compiler inferring
Nothing
orNull
.@explicitGenerics def readJson[T: GenCodec](json: String): T = ... // raise error, because otherwise we have a hidden bug - the compiler infers `Nothing` in place of `T` val x: MyType = readJson("{}") // ok val x = readJson[MyType]("{}")
-
class
macroPrivate extends Annotation with StaticAnnotation
Symbols annotated with this annotation can only be used in macro-generated code.
-
class
positioned extends Annotation with StaticAnnotation
Annotate a symbol (i.e.
Annotate a symbol (i.e. class, method, parameter, etc.) with
@positioned(positioned.here)
to retain source position information for that symbol to be available in macro implementations which inspect that symbol. This is necessary e.g. for determining declaration order of subtypes of sealed hierarchies in macro implementations. This annotation is only needed when macro is invoked in a different source file than the source file of inspected symbol. If macro is invoked in the same file, source position is always available. -
class
showAst extends Annotation with StaticAnnotation
When applied on a definition (
class
,object
,def
,val
, etc.) or expression, will cause the AVSystem static analyzer to print compilation error with AST of annotated code fragment.When applied on a definition (
class
,object
,def
,val
, etc.) or expression, will cause the AVSystem static analyzer to print compilation error with AST of annotated code fragment. This is useful primarily for debugging macro expansions.
Value Members
- object positioned