@@ -20,6 +20,8 @@ object Annotations {
20
20
21
21
def symbol (using Context ): Symbol = annotClass(tree)
22
22
23
+ def hasSymbol (sym : Symbol )(using Context ) = symbol == sym
24
+
23
25
def matches (cls : Symbol )(using Context ): Boolean = symbol.derivesFrom(cls)
24
26
25
27
def appliesToModule : Boolean = true // for now; see remark in SymDenotations
@@ -127,6 +129,11 @@ object Annotations {
127
129
override def isEvaluated : Boolean = myTree.isInstanceOf [Tree @ unchecked]
128
130
}
129
131
132
+ class DeferredSymAndTree (symFn : Context ?=> Symbol , treeFn : Context ?=> Tree )
133
+ extends LazyAnnotation :
134
+ protected var mySym : Symbol | (Context ?=> Symbol ) | Null = ctx ?=> symFn(using ctx)
135
+ protected var myTree : Tree | (Context ?=> Tree ) | Null = ctx ?=> treeFn(using ctx)
136
+
130
137
/** An annotation indicating the body of a right-hand side,
131
138
* typically of an inline method. Treated specially in
132
139
* pickling/unpickling and TypeTreeMaps
@@ -193,18 +200,15 @@ object Annotations {
193
200
apply(New (atp, args))
194
201
195
202
/** Create an annotation where the tree is computed lazily. */
196
- def deferred (sym : Symbol )(treeFn : Context ?=> Tree )( using Context ) : Annotation =
203
+ def deferred (sym : Symbol )(treeFn : Context ?=> Tree ): Annotation =
197
204
new LazyAnnotation {
198
205
protected var myTree : Tree | (Context ?=> Tree ) | Null = ctx ?=> treeFn(using ctx)
199
206
protected var mySym : Symbol | (Context ?=> Symbol ) | Null = sym
200
207
}
201
208
202
209
/** Create an annotation where the symbol and the tree are computed lazily. */
203
- def deferredSymAndTree (symFn : Context ?=> Symbol )(treeFn : Context ?=> Tree )(using Context ): Annotation =
204
- new LazyAnnotation {
205
- protected var mySym : Symbol | (Context ?=> Symbol ) | Null = ctx ?=> symFn(using ctx)
206
- protected var myTree : Tree | (Context ?=> Tree ) | Null = ctx ?=> treeFn(using ctx)
207
- }
210
+ def deferredSymAndTree (symFn : Context ?=> Symbol )(treeFn : Context ?=> Tree ): Annotation =
211
+ DeferredSymAndTree (symFn, treeFn)
208
212
209
213
/** Extractor for child annotations */
210
214
object Child {
0 commit comments