You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
THis is possible now that we have access to information
about the outer inlined tree nodes via enclosingInlineds.
In particular we can recover the position where the macro was inlined.
else if (enclosingInlineds.nonEmpty) { // level 0 in an inlined call
422
+
val spliceCtx = ctx.outer // drop the last `inlineContext`
423
+
val pos: SourcePosition = Decorators.sourcePos(enclosingInlineds.head.pos)(spliceCtx)
424
+
val evaluatedSplice = Splicer.splice(splice.qualifier, pos, macroClassLoader)(spliceCtx).withPos(splice.pos)
425
+
if (ctx.reporter.hasErrors) splice else transform(evaluatedSplice)
426
+
}
427
+
else if (!ctx.owner.is(Transparent)) { // level 0 outside a transparent definition
428
+
ctx.error(i"splice outside quotes or transparent method", splice.pos)
429
+
splice
430
+
}
431
+
else if (Splicer.canBeSpliced(splice.qualifier)) { // level 0 inside a transparent definition
432
+
nested(isQuote = false).split(splice.qualifier) // Just check PCP
433
+
splice
434
+
}
435
+
else { // level 0 inside a transparent definition
436
+
ctx.error("Malformed macro call. The contents of the ~ must call a static method and arguments must be quoted or transparent.".stripMargin, splice.pos)
437
+
splice
438
+
}
429
439
}
430
440
431
441
/** Transforms the contents of a nested splice
@@ -550,18 +560,6 @@ class ReifyQuotes extends MacroTransformWithImplicits {
550
560
val last = enteredSyms
551
561
stats.foreach(markDef)
552
562
mapOverTree(last)
553
-
case Inlined(call, bindings, InlineSplice(spliced)) if !call.isEmpty =>
554
-
val tree2 =
555
-
if (level == 0) {
556
-
val evaluatedSplice = Splicer.splice(spliced, tree.pos, macroClassLoader).withPos(tree.pos)
0 commit comments