From c0e1279870abeda8995ce1a2c16acf9af50bc648 Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Mon, 30 Jul 2018 18:16:33 +0200 Subject: [PATCH 1/2] Add some post conditions to ReifyQuotes --- .../dotty/tools/dotc/transform/ReifyQuotes.scala | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index ded1a950be50..86a642c1b97f 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -74,6 +74,19 @@ class ReifyQuotes extends MacroTransformWithImplicits { override def phaseName: String = "reifyQuotes" + override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { + val inTransparentMethod = ctx.owner.ownersIterator.exists(_.isTransparentMethod) + tree match { + case tree: RefTree if !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 From 9f7a8b4a8bd10a23f074ede61c634bc76e9dc30b Mon Sep 17 00:00:00 2001 From: Nicolas Stucki Date: Tue, 31 Jul 2018 10:22:47 +0200 Subject: [PATCH 2/2] Update ReifyQuotes.scala --- compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala index 86a642c1b97f..c435144a5b77 100644 --- a/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala +++ b/compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala @@ -75,9 +75,8 @@ class ReifyQuotes extends MacroTransformWithImplicits { override def phaseName: String = "reifyQuotes" override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { - val inTransparentMethod = ctx.owner.ownersIterator.exists(_.isTransparentMethod) tree match { - case tree: RefTree if !inTransparentMethod => + 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_~)