@@ -83,7 +83,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
83
83
if (ctx.compilationUnit.needsStaging) super .run
84
84
85
85
protected def newTransformer (implicit ctx : Context ): Transformer =
86
- new Reifier (inQuote = false , null , new LevelInfo , new Embedded , ctx)
86
+ new Reifier (null , new LevelInfo , new Embedded , ctx)
87
87
88
88
private class LevelInfo {
89
89
/** A map from locally defined symbols to the staging levels of their definitions */
@@ -115,14 +115,14 @@ class ReifyQuotes extends MacroTransformWithImplicits {
115
115
* @param embedded a list of embedded quotes (if `inSplice = true`) or splices (if `inQuote = true`
116
116
* @param rctx the contex in the destination lifted lambda
117
117
*/
118
- private class Reifier (inQuote : Boolean , val outer : Reifier , levels : LevelInfo ,
118
+ private class Reifier (val outer : Reifier , levels : LevelInfo ,
119
119
val embedded : Embedded , val rctx : Context ) extends ImplicitsTransformer {
120
120
import levels ._
121
121
122
122
/** A nested reifier for a quote (if `isQuote = true`) or a splice (if not) */
123
123
def nested (isQuote : Boolean )(implicit ctx : Context ): Reifier = {
124
124
val nestedEmbedded = if (quotationLevel > 1 || (quotationLevel == 1 && isQuote)) embedded else new Embedded
125
- new Reifier (isQuote, this , levels, nestedEmbedded, ctx)
125
+ new Reifier (this , levels, nestedEmbedded, ctx)
126
126
}
127
127
128
128
/** We are not in a `~(...)` or a `'(...)` */
@@ -369,7 +369,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
369
369
// in '{ x } to '{ x$1.unary_~ } and go directly to `x$1`
370
370
capturers(body.symbol)(body)
371
371
case _=>
372
- val (body1, splices) = nested(isQuote = true ).split (body)(quoteContext)
372
+ val (body1, splices) = nested(isQuote = true ).splitQuote (body)(quoteContext)
373
373
if (quotationLevel == 0 && ! ctx.inInlineMethod) {
374
374
val body2 =
375
375
if (body1.isType) body1
@@ -424,7 +424,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
424
424
body1.select(splice.name)
425
425
}
426
426
else if (quotationLevel == 1 ) {
427
- val (body1, quotes) = nested(isQuote = false ).split (splice.qualifier)(spliceContext)
427
+ val (body1, quotes) = nested(isQuote = false ).splitSplice (splice.qualifier)(spliceContext)
428
428
val tpe = outer.embedded.getHoleType(splice)
429
429
val hole = makeHole(body1, quotes, tpe).withSpan(splice.span)
430
430
// We do not place add the inline marker for trees that where lifted as they come from the same file as their
@@ -441,7 +441,7 @@ class ReifyQuotes extends MacroTransformWithImplicits {
441
441
}
442
442
else if (Splicer .canBeSpliced(splice.qualifier)) { // level 0 inside an inline definition
443
443
// TODO remove?
444
- nested(isQuote = false ).split (splice.qualifier)(spliceContext) // Just check PCP
444
+ nested(isQuote = false ).transform (splice.qualifier)(spliceContext) // Just check PCP
445
445
splice
446
446
}
447
447
else { // level 0 inside an inline definition
@@ -537,8 +537,13 @@ class ReifyQuotes extends MacroTransformWithImplicits {
537
537
/** Transform `tree` and return the resulting tree and all `embedded` quotes
538
538
* or splices as a pair, after performing the `addTags` transform.
539
539
*/
540
- private def split (tree : Tree )(implicit ctx : Context ): (Tree , List [Tree ]) = {
541
- val tree1 = if (inQuote) addTags(transform(tree)) else makeLambda(tree)
540
+ private def splitQuote (tree : Tree )(implicit ctx : Context ): (Tree , List [Tree ]) = {
541
+ val tree1 = addTags(transform(tree))
542
+ (tree1, embedded.getTrees)
543
+ }
544
+
545
+ private def splitSplice (tree : Tree )(implicit ctx : Context ): (Tree , List [Tree ]) = {
546
+ val tree1 = makeLambda(tree)
542
547
(tree1, embedded.getTrees)
543
548
}
544
549
@@ -614,11 +619,6 @@ class ReifyQuotes extends MacroTransformWithImplicits {
614
619
EmptyTree
615
620
}
616
621
case _ =>
617
- // println("------------------------")
618
- // println(tree.show)
619
- // println(tree)
620
- // println()
621
- // println()
622
622
markDef(tree)
623
623
checkLevel(mapOverTree(enteredSyms))
624
624
}
0 commit comments