Skip to content

Add some post conditions to ReifyQuotes #4870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ class ReifyQuotes extends MacroTransformWithImplicits {

override def phaseName: String = "reifyQuotes"

override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = {
tree match {
case tree: RefTree if !ctx.inTransparentMethod =>
assert(!tree.symbol.isQuote)
// assert(!tree.symbol.isSplice) // TODO widen ~ type references at stage 0?
assert(tree.symbol != defn.QuotedExpr_~)
case tree: Select if tree.symbol == defn.QuotedExpr_~ =>
assert(Splicer.canBeSpliced(tree.qualifier))
case _ =>
}
}

override def run(implicit ctx: Context): Unit =
if (ctx.compilationUnit.containsQuotesOrSplices) super.run

Expand Down