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
Fix#4801: Allow top-level splices not directly in the RHS
For example a transparent method can be defined as
```
transparent def foo(b: Boolean): Int =
if (b) ~bar(true)
else ~bar(false)
```
Removing this restriction also allows us to have a simpler implementation
of splicing and transparent def checking.
if (ctx.reporter.hasErrors) splice else transform(evaluatedSplice)
426
+
}
427
+
elseif (!ctx.owner.ownersIterator.exists(_.is(Transparent))) { // level 0 outside a transparent definition
428
+
ctx.error(i"splice outside quotes or transparent method", splice.pos)
429
+
splice
430
+
}
431
+
elseif (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,39 +560,10 @@ class ReifyQuotes extends MacroTransformWithImplicits {
0 commit comments