@@ -92,28 +92,19 @@ class Staging extends MacroTransformWithImplicits {
92
92
override def run (implicit ctx : Context ): Unit =
93
93
if (ctx.compilationUnit.needsStaging) super .run
94
94
95
- protected def newTransformer (implicit ctx : Context ): Transformer =
96
- new Reifier (new LevelInfo )
97
-
98
- private class LevelInfo {
99
- /** A map from locally defined symbols to the staging levels of their definitions */
100
- val levelOf = new mutable.HashMap [Symbol , Int ]
101
- }
95
+ protected def newTransformer (implicit ctx : Context ): Transformer = new Reifier ()
102
96
103
97
/** The main transformer class
104
98
* @param level the current level, where quotes add one and splices subtract one level.
105
99
* The initial level is 0, a level `l` where `l > 0` implies code has been quoted `l` times
106
100
* and `l == -1` is code inside a top level splice (in an inline method).
107
101
* @param levels a stacked map from symbols to the levels in which they were defined
108
102
*/
109
- private class Reifier (levels : LevelInfo )
103
+ private class Reifier ()
110
104
extends ImplicitsTransformer {
111
- import levels ._
112
105
113
- /** A nested reifier for a quote (if `isQuote = true`) or a splice (if not) */
114
- def nested (isQuote : Boolean )(implicit ctx : Context ): Reifier = {
115
- new Reifier (levels)
116
- }
106
+ /** A map from locally defined symbols to the staging levels of their definitions */
107
+ val levelOf = new mutable.HashMap [Symbol , Int ]
117
108
118
109
/** A stack of entered symbols, to be unwound after scope exit */
119
110
var enteredSyms : List [Symbol ] = Nil
@@ -278,12 +269,12 @@ class Staging extends MacroTransformWithImplicits {
278
269
private def quotation (body : Tree , quote : Tree )(implicit ctx : Context ): Tree = {
279
270
val isType = quote.symbol eq defn.QuotedType_apply
280
271
if (quotationLevel > 0 ) {
281
- val body1 = nested(isQuote = true ). transform(body)(quoteContext)
272
+ val body1 = transform(body)(quoteContext)
282
273
// Keep quotes as trees to reduce pickled size and have a Expr.show without pickled quotes
283
274
if (isType) ref(defn.QuotedType_apply ).appliedToType(body1.tpe.widen)
284
275
else ref(defn.QuotedExpr_apply ).appliedToType(body1.tpe.widen).appliedTo(body1)
285
276
} else {
286
- val body1 = nested(isQuote = true ). transform(body)(quoteContext)
277
+ val body1 = transform(body)(quoteContext)
287
278
if (quotationLevel == 0 && ! ctx.inInlineMethod) {
288
279
quote match {
289
280
case quote : Apply => cpy.Apply (quote)(quote.fun, body1 :: Nil )
@@ -303,7 +294,7 @@ class Staging extends MacroTransformWithImplicits {
303
294
*/
304
295
private def splice (splice : Select )(implicit ctx : Context ): Tree = {
305
296
if (quotationLevel >= 1 ) {
306
- val body1 = nested(isQuote = false ). transform(splice.qualifier)(spliceContext)
297
+ val body1 = transform(splice.qualifier)(spliceContext)
307
298
body1.select(splice.name)
308
299
}
309
300
else if (enclosingInlineds.nonEmpty) { // quotationLevel 0 in an inlined call
@@ -317,7 +308,7 @@ class Staging extends MacroTransformWithImplicits {
317
308
splice
318
309
}
319
310
else if (Splicer .canBeSpliced(splice.qualifier)) { // quotationLevel 0 inside an inline definition
320
- nested(isQuote = false ). transform(splice.qualifier)(spliceContext) // Just check PCP
311
+ transform(splice.qualifier)(spliceContext) // Just check PCP
321
312
}
322
313
else { // quotationLevel 0 inside an inline definition
323
314
ctx.error(
0 commit comments