@@ -73,19 +73,19 @@ class ReifyQuotes extends MacroTransformWithImplicits {
73
73
val levelOf = new mutable.HashMap [Symbol , Int ]
74
74
75
75
/** Register a reference defined in a quote but used in another quote nested in a splice.
76
- * Returns a lifted version of the reference that needs to be used in its place.
76
+ * Returns a version of the reference that needs to be used in its place.
77
77
* '{
78
78
* val x = ???
79
79
* { ... '{ ... x ... } ... }.unary_~
80
80
* }
81
- * Lifting the `x` in `{ ... '{ ... x ... } ... }.unary_~` will return a `x$1.unary_~` for which the `x$1`
81
+ * Eta expanding the `x` in `{ ... '{ ... x ... } ... }.unary_~` will return a `x$1.unary_~` for which the `x$1`
82
82
* be created by some outer reifier.
83
83
*
84
84
* This transformation is only applied to definitions at staging level 1.
85
85
*
86
- * See `needsLifting `
86
+ * See `isCaptured `
87
87
*/
88
- val lifters = new mutable.HashMap [Symbol , RefTree => Tree ]
88
+ val capturers = new mutable.HashMap [Symbol , RefTree => Tree ]
89
89
}
90
90
91
91
/** The main transformer class
@@ -348,7 +348,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
348
348
* { ... '{ ... x$1.unary_~ ... y$1.unary_~ ... } ... }
349
349
* }
350
350
*
351
- * See: `lift `
351
+ * See: `capture `
352
352
*
353
353
* At the same time register `embedded` trees `x` and `y` to place as arguments of the hole
354
354
* placed in the original code.
@@ -361,17 +361,17 @@ class ReifyQuotes extends MacroTransformWithImplicits {
361
361
private def makeLambda (tree : Tree )(implicit ctx : Context ): Tree = {
362
362
def body (arg : Tree )(implicit ctx : Context ): Tree = {
363
363
var i = 0
364
- transformWithLifter (tree)(
365
- (lifted : mutable.ListBuffer [Tree ]) => (tree : RefTree ) => {
364
+ transformWithCapturer (tree)(
365
+ (captured : mutable.ListBuffer [Tree ]) => (tree : RefTree ) => {
366
366
val argTpe =
367
367
if (tree.isTerm) defn.QuotedExprType .appliedTo(tree.tpe.widen)
368
368
else defn.QuotedTypeType .appliedTo(defn.AnyType )
369
369
val selectArg = arg.select(nme.apply).appliedTo(Literal (Constant (i))).asInstance(argTpe)
370
- val liftedArg = SyntheticValDef (UniqueName .fresh(tree.name.toTermName).toTermName, selectArg)
370
+ val capturedArg = SyntheticValDef (UniqueName .fresh(tree.name.toTermName).toTermName, selectArg)
371
371
i += 1
372
372
embedded += tree
373
- lifted += liftedArg
374
- ref(liftedArg .symbol)
373
+ captured += capturedArg
374
+ ref(capturedArg .symbol)
375
375
}
376
376
)
377
377
}
@@ -382,21 +382,21 @@ class ReifyQuotes extends MacroTransformWithImplicits {
382
382
Closure (meth, tss => body(tss.head.head)(ctx.withOwner(meth)).changeOwner(ctx.owner, meth))
383
383
}
384
384
385
- private def transformWithLifter (tree : Tree )(
386
- lifter : mutable.ListBuffer [Tree ] => RefTree => Tree )(implicit ctx : Context ): Tree = {
387
- val lifted = new mutable.ListBuffer [Tree ]
388
- val lifter2 = lifter(lifted )
389
- outer.enteredSyms.foreach(s => lifters .put(s, lifter2 ))
385
+ private def transformWithCapturer (tree : Tree )(
386
+ capturer : mutable.ListBuffer [Tree ] => RefTree => Tree )(implicit ctx : Context ): Tree = {
387
+ val captured = new mutable.ListBuffer [Tree ]
388
+ val captured2 = capturer(captured )
389
+ outer.enteredSyms.foreach(s => capturers .put(s, captured2 ))
390
390
val tree2 = transform(tree)
391
- lifters --= outer.enteredSyms
392
- seq(lifted .result(), tree2)
391
+ capturers --= outer.enteredSyms
392
+ seq(captured .result(), tree2)
393
393
}
394
394
395
- /** Returns true if this tree will be lifted by `makeLambda` */
396
- private def needsLifting (tree : RefTree )(implicit ctx : Context ): Boolean = {
397
- // Check phase consistency and presence of lifter
395
+ /** Returns true if this tree will be captured by `makeLambda` */
396
+ private def isCaptured (tree : RefTree )(implicit ctx : Context ): Boolean = {
397
+ // Check phase consistency and presence of capturer
398
398
level == 1 && ! tree.symbol.is(Inline ) && levelOf.get(tree.symbol).contains(1 ) &&
399
- lifters .contains(tree.symbol)
399
+ capturers .contains(tree.symbol)
400
400
}
401
401
402
402
/** Transform `tree` and return the resulting tree and all `embedded` quotes
@@ -430,9 +430,9 @@ class ReifyQuotes extends MacroTransformWithImplicits {
430
430
quotation(quotedTree, tree)
431
431
case tree : Select if tree.symbol.isSplice =>
432
432
splice(tree)
433
- case tree : RefTree if needsLifting (tree) =>
434
- val lift = lifters (tree.symbol)
435
- splice(lift (tree).select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~ ))
433
+ case tree : RefTree if isCaptured (tree) =>
434
+ val capturer = capturers (tree.symbol)
435
+ splice(capturer (tree).select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~ ))
436
436
case Block (stats, _) =>
437
437
val last = enteredSyms
438
438
stats.foreach(markDef)
0 commit comments