@@ -236,7 +236,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
236
236
case tree : DefTree =>
237
237
val sym = tree.symbol
238
238
if ((sym.isClass || ! sym.maybeOwner.isType) && ! levelOf.contains(sym)) {
239
- levelOf(sym) = level
239
+ levelOf(sym) = if (sym.is( Inline )) level - 1 else level
240
240
enteredSyms = sym :: enteredSyms
241
241
}
242
242
case _ =>
@@ -250,7 +250,7 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
250
250
def levelOK (sym : Symbol )(implicit ctx : Context ): Boolean = levelOf.get(sym) match {
251
251
case Some (l) =>
252
252
l == level ||
253
- l == 1 && level == 0 && isStage0Value(sym)
253
+ ( 0 == level && isStage0Value(sym) )
254
254
case None =>
255
255
! sym.is(Param ) || levelOK(sym.owner)
256
256
}
@@ -384,15 +384,9 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
384
384
}
385
385
else body match {
386
386
case body : RefTree if isCaptured(body.symbol, level + 1 ) =>
387
- if (isStage0Value(body.symbol)) {
388
- // Optimization: avoid the full conversion when capturing inlined `x`
389
- // in '{ x } to '{ x$1.toExpr.unary_~ } and go directly to `x$1.toExpr`
390
- liftValue(capturers(body.symbol)(body))
391
- } else {
392
- // Optimization: avoid the full conversion when capturing `x`
393
- // in '{ x } to '{ x$1.unary_~ } and go directly to `x$1`
394
- capturers(body.symbol)(body)
395
- }
387
+ // Optimization: avoid the full conversion when capturing `x`
388
+ // in '{ x } to '{ x$1.unary_~ } and go directly to `x$1`
389
+ capturers(body.symbol)(body)
396
390
case _=>
397
391
val (body1, splices) = nested(isQuote = true ).split(body)
398
392
pickledQuote(body1, splices, body.tpe, isType).withPos(quote.pos)
@@ -575,9 +569,8 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
575
569
val capturer = capturers(tree.symbol)
576
570
def captureAndSplice (t : Tree ) =
577
571
splice(t.select(if (tree.isTerm) nme.UNARY_~ else tpnme.UNARY_~ ))
578
- if (! isStage0Value(tree.symbol)) captureAndSplice(capturer(tree))
579
- else if (level == 0 ) capturer(tree)
580
- else captureAndSplice(liftValue(capturer(tree)))
572
+ if (level == 0 && isStage0Value(tree.symbol)) capturer(tree)
573
+ else captureAndSplice(capturer(tree))
581
574
case Block (stats, _) =>
582
575
val last = enteredSyms
583
576
stats.foreach(markDef)
@@ -632,21 +625,6 @@ class ReifyQuotes extends MacroTransformWithImplicits with InfoTransformer {
632
625
}
633
626
}
634
627
635
- private def liftValue (tree : Tree )(implicit ctx : Context ): Tree = {
636
- val reqType = defn.QuotedLiftableType .appliedTo(tree.tpe.widen)
637
- val liftable = ctx.typer.inferImplicitArg(reqType, tree.pos)
638
- liftable.tpe match {
639
- case fail : SearchFailureType =>
640
- ctx.error(i """
641
- |
642
- | The access would be accepted with the right Liftable, but
643
- | ${ctx.typer.missingArgMsg(liftable, reqType, " " )}""" )
644
- EmptyTree
645
- case _ =>
646
- liftable.select(" toExpr" .toTermName).appliedTo(tree)
647
- }
648
- }
649
-
650
628
private def isStage0Value (sym : Symbol )(implicit ctx : Context ): Boolean =
651
629
(sym.is(Inline ) && sym.owner.is(Macro ) && ! defn.isFunctionType(sym.info)) ||
652
630
sym == defn.TastyTopLevelSplice_compilationTopLevelSplice // intrinsic value at stage 0
0 commit comments