Skip to content

Commit 0fa510a

Browse files
committed
Encode default args of annotations in a meta annotation
... and use the defaults at callsites
1 parent d699135 commit 0fa510a

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Scala (https://www.scala-lang.org)
3+
*
4+
* Copyright EPFL and Lightbend, Inc. dba Akka
5+
*
6+
* Licensed under Apache License 2.0
7+
* (http://www.apache.org/licenses/LICENSE-2.0).
8+
*
9+
* See the NOTICE file distributed with this work for
10+
* additional information regarding copyright ownership.
11+
*/
12+
13+
package scala.annotation
14+
package meta
15+
16+
/**
17+
* This internal meta annotation is used by the compiler to support default annotation arguments.
18+
*
19+
* For an annotation definition `class ann(x: Int = defaultExpr) extends Annotation`, the compiler adds
20+
* `@defaultArg(defaultExpr)` to the parameter `x`. This causes the syntax tree of `defaultExpr` to be
21+
* stored in the classfile.
22+
*
23+
* When using a default annotation argument, the compiler can recover the syntax tree and insert it in the
24+
* `AnnotationInfo`.
25+
*
26+
* For details, see `scala.reflect.internal.AnnotationInfos.AnnotationInfo`.
27+
*/
28+
@meta.param class defaultArg(arg: Any) extends StaticAnnotation {
29+
def this() = this(null)
30+
}

0 commit comments

Comments
 (0)