Skip to content

Commit cc3bec1

Browse files
Merge pull request #4870 from dotty-staging/add-postcondition-in-reify-quotes
Add some post conditions to ReifyQuotes
2 parents e72b80b + 9f7a8b4 commit cc3bec1

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ class ReifyQuotes extends MacroTransformWithImplicits {
7474

7575
override def phaseName: String = "reifyQuotes"
7676

77+
override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = {
78+
tree match {
79+
case tree: RefTree if !ctx.inTransparentMethod =>
80+
assert(!tree.symbol.isQuote)
81+
// assert(!tree.symbol.isSplice) // TODO widen ~ type references at stage 0?
82+
assert(tree.symbol != defn.QuotedExpr_~)
83+
case tree: Select if tree.symbol == defn.QuotedExpr_~ =>
84+
assert(Splicer.canBeSpliced(tree.qualifier))
85+
case _ =>
86+
}
87+
}
88+
7789
override def run(implicit ctx: Context): Unit =
7890
if (ctx.compilationUnit.containsQuotesOrSplices) super.run
7991

0 commit comments

Comments
 (0)