@@ -51,36 +51,27 @@ object Annotations {
51
51
def tree (using Context ): Tree = t
52
52
}
53
53
54
- /** The context to use to evaluate an annotation */
55
- private def annotCtx (using Context ): Context =
56
- // We should always produce the same annotation tree, no matter when the
57
- // annotation is evaluated. Setting the phase to a pre-transformation phase
58
- // seems to be enough to ensure this (note that after erasure, `ctx.typer`
59
- // will be the Erasure typer, but that doesn't seem to affect the annotation
60
- // trees we create, so we leave it as is)
61
- ctx.withPhaseNoLater(picklerPhase)
62
-
63
54
abstract class LazyAnnotation extends Annotation {
64
- protected var mySym : Symbol | (Context => Symbol )
55
+ protected var mySym : Symbol | (Context ? => Symbol )
65
56
override def symbol (using parentCtx : Context ): Symbol =
66
57
assert(mySym != null )
67
58
mySym match {
68
- case symFn : (Context => Symbol ) @ unchecked =>
59
+ case symFn : (Context ? => Symbol ) @ unchecked =>
69
60
mySym = null
70
- mySym = symFn(annotCtx )
61
+ mySym = atPhaseNoLater(picklerPhase)(symFn )
71
62
case sym : Symbol if sym.defRunId != currentRunId(using parentCtx) =>
72
63
mySym = sym.denot.current.symbol
73
64
case _ =>
74
65
}
75
66
mySym.asInstanceOf [Symbol ]
76
67
77
- protected var myTree : Tree | (Context => Tree )
68
+ protected var myTree : Tree | (Context ? => Tree )
78
69
def tree (using Context ): Tree =
79
70
assert(myTree != null )
80
71
myTree match {
81
- case treeFn : (Context => Tree ) @ unchecked =>
72
+ case treeFn : (Context ? => Tree ) @ unchecked =>
82
73
myTree = null
83
- myTree = treeFn(annotCtx )
74
+ myTree = atPhaseNoLater(picklerPhase)(treeFn )
84
75
case _ =>
85
76
}
86
77
myTree.asInstanceOf [Tree ]
@@ -107,13 +98,13 @@ object Annotations {
107
98
108
99
abstract class LazyBodyAnnotation extends BodyAnnotation {
109
100
// Copy-pasted from LazyAnnotation to avoid having to turn it into a trait
110
- protected var myTree : Tree | (Context => Tree )
101
+ protected var myTree : Tree | (Context ? => Tree )
111
102
def tree (using Context ): Tree =
112
103
assert(myTree != null )
113
104
myTree match {
114
- case treeFn : (Context => Tree ) @ unchecked =>
105
+ case treeFn : (Context ? => Tree ) @ unchecked =>
115
106
myTree = null
116
- myTree = treeFn(annotCtx )
107
+ myTree = atPhaseNoLater(picklerPhase)(treeFn )
117
108
case _ =>
118
109
}
119
110
myTree.asInstanceOf [Tree ]
@@ -125,7 +116,7 @@ object Annotations {
125
116
object LazyBodyAnnotation {
126
117
def apply (bodyFn : Context ?=> Tree ): LazyBodyAnnotation =
127
118
new LazyBodyAnnotation :
128
- protected var myTree : Tree | (Context => Tree ) = ctx => bodyFn(using ctx)
119
+ protected var myTree : Tree | (Context ? => Tree ) = ( using ctx) => bodyFn(using ctx)
129
120
}
130
121
131
122
object Annotation {
@@ -156,15 +147,15 @@ object Annotations {
156
147
/** Create an annotation where the tree is computed lazily. */
157
148
def deferred (sym : Symbol )(treeFn : Context ?=> Tree )(using Context ): Annotation =
158
149
new LazyAnnotation {
159
- protected var myTree : Tree | (Context => Tree ) = ctx => treeFn(using ctx)
160
- protected var mySym : Symbol | (Context => Symbol ) = sym
150
+ protected var myTree : Tree | (Context ? => Tree ) = ( using ctx) => treeFn(using ctx)
151
+ protected var mySym : Symbol | (Context ? => Symbol ) = sym
161
152
}
162
153
163
154
/** Create an annotation where the symbol and the tree are computed lazily. */
164
155
def deferredSymAndTree (symFn : Context ?=> Symbol )(treeFn : Context ?=> Tree )(using Context ): Annotation =
165
156
new LazyAnnotation {
166
- protected var mySym : Symbol | (Context => Symbol ) = ctx => symFn(using ctx)
167
- protected var myTree : Tree | (Context => Tree ) = ctx => treeFn(using ctx)
157
+ protected var mySym : Symbol | (Context ? => Symbol ) = ( using ctx) => symFn(using ctx)
158
+ protected var myTree : Tree | (Context ? => Tree ) = ( using ctx) => treeFn(using ctx)
168
159
}
169
160
170
161
def deferred (atp : Type , args : List [Tree ])(using Context ): Annotation =
0 commit comments