@@ -73,19 +73,19 @@ class ReifyQuotes extends MacroTransformWithImplicits {
7373 val levelOf = new mutable.HashMap [Symbol , Int ]
7474
7575 /** 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.
7777 * '{
7878 * val x = ???
7979 * { ... '{ ... x ... } ... }.unary_~
8080 * }
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`
8282 * be created by some outer reifier.
8383 *
8484 * This transformation is only applied to definitions at staging level 1.
8585 *
86- * See `needsLifting `
86+ * See `isCaptured `
8787 */
88- val lifters = new mutable.HashMap [Symbol , RefTree => Tree ]
88+ val capturers = new mutable.HashMap [Symbol , RefTree => Tree ]
8989 }
9090
9191 /** The main transformer class
@@ -348,7 +348,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
348348 * { ... '{ ... x$1.unary_~ ... y$1.unary_~ ... } ... }
349349 * }
350350 *
351- * See: `lift `
351+ * See: `capture `
352352 *
353353 * At the same time register `embedded` trees `x` and `y` to place as arguments of the hole
354354 * placed in the original code.
@@ -361,17 +361,17 @@ class ReifyQuotes extends MacroTransformWithImplicits {
361361 private def makeLambda (tree : Tree )(implicit ctx : Context ): Tree = {
362362 def body (arg : Tree )(implicit ctx : Context ): Tree = {
363363 var i = 0
364- transformWithLifter (tree)(
365- (lifted : mutable.ListBuffer [Tree ]) => (tree : RefTree ) => {
364+ transformWithCapturer (tree)(
365+ (captured : mutable.ListBuffer [Tree ]) => (tree : RefTree ) => {
366366 val argTpe =
367367 if (tree.isTerm) defn.QuotedExprType .appliedTo(tree.tpe.widen)
368368 else defn.QuotedTypeType .appliedTo(defn.AnyType )
369369 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)
371371 i += 1
372372 embedded += tree
373- lifted += liftedArg
374- ref(liftedArg .symbol)
373+ captured += capturedArg
374+ ref(capturedArg .symbol)
375375 }
376376 )
377377 }
@@ -382,21 +382,21 @@ class ReifyQuotes extends MacroTransformWithImplicits {
382382 Closure (meth, tss => body(tss.head.head)(ctx.withOwner(meth)).changeOwner(ctx.owner, meth))
383383 }
384384
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 ))
390390 val tree2 = transform(tree)
391- lifters --= outer.enteredSyms
392- seq(lifted .result(), tree2)
391+ capturers --= outer.enteredSyms
392+ seq(captured .result(), tree2)
393393 }
394394
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
398398 level == 1 && ! tree.symbol.is(Inline ) && levelOf.get(tree.symbol).contains(1 ) &&
399- lifters .contains(tree.symbol)
399+ capturers .contains(tree.symbol)
400400 }
401401
402402 /** Transform `tree` and return the resulting tree and all `embedded` quotes
@@ -430,9 +430,9 @@ class ReifyQuotes extends MacroTransformWithImplicits {
430430 quotation(quotedTree, tree)
431431 case tree : Select if tree.symbol.isSplice =>
432432 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_~ ))
436436 case Block (stats, _) =>
437437 val last = enteredSyms
438438 stats.foreach(markDef)
0 commit comments