@@ -20,6 +20,8 @@ object Annotations {
2020
2121 def symbol (using Context ): Symbol = annotClass(tree)
2222
23+ def hasSymbol (sym : Symbol )(using Context ) = symbol == sym
24+
2325 def matches (cls : Symbol )(using Context ): Boolean = symbol.derivesFrom(cls)
2426
2527 def appliesToModule : Boolean = true // for now; see remark in SymDenotations
@@ -127,6 +129,11 @@ object Annotations {
127129 override def isEvaluated : Boolean = myTree.isInstanceOf [Tree @ unchecked]
128130 }
129131
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+
130137 /** An annotation indicating the body of a right-hand side,
131138 * typically of an inline method. Treated specially in
132139 * pickling/unpickling and TypeTreeMaps
@@ -193,18 +200,15 @@ object Annotations {
193200 apply(New (atp, args))
194201
195202 /** 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 =
197204 new LazyAnnotation {
198205 protected var myTree : Tree | (Context ?=> Tree ) | Null = ctx ?=> treeFn(using ctx)
199206 protected var mySym : Symbol | (Context ?=> Symbol ) | Null = sym
200207 }
201208
202209 /** 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)
208212
209213 /** Extractor for child annotations */
210214 object Child {
0 commit comments