diff --git a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala index 07a52d32a778..bcd80977efd5 100644 --- a/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala +++ b/compiler/src/dotty/tools/dotc/config/ScalaSettings.scala @@ -116,6 +116,7 @@ class ScalaSettings extends Settings.SettingGroup { val YprintDebug: Setting[Boolean] = BooleanSetting("-Yprint-debug", "when printing trees, print some extra information useful for debugging.") val YprintDebugOwners: Setting[Boolean] = BooleanSetting("-Yprint-debug-owners", "when printing trees, print owners of definitions.") val YshowPrintErrors: Setting[Boolean] = BooleanSetting("-Yshow-print-errors", "don't suppress exceptions thrown during tree printing.") + val YshowRawQuoteTrees: Setting[Boolean] = BooleanSetting("-Yshow-raw-tree", "don't remove quote artifacts") val YtestPickler: Setting[Boolean] = BooleanSetting("-Ytest-pickler", "self-test for pickling functionality; should be used with -Ystop-after:pickler") val YcheckReentrant: Setting[Boolean] = BooleanSetting("-Ycheck-reentrant", "check that compiled program does not contain vars that can be accessed from a global root.") val YdropComments: Setting[Boolean] = BooleanSetting("-Ydrop-comments", "Drop comments when scanning source files.") diff --git a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala index bc02a840a886..ccc2a33aa43d 100644 --- a/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala +++ b/compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala @@ -27,7 +27,7 @@ class QuoteDriver extends Driver { } val (_, ctx0: Context) = setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh) - val ctx = setColor(ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir), settings) + val ctx = setToolboxSettings(ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir), settings) val driver = new QuoteCompiler driver.newRun(ctx).compileExpr(expr) @@ -43,14 +43,17 @@ class QuoteDriver extends Driver { def show(expr: Expr[_], settings: Toolbox.Settings): String = { def show(tree: Tree, ctx: Context): String = { - val tree1 = if (settings.showRawTree) tree else (new TreeCleaner).transform(tree)(ctx) - new TastyImpl(ctx).showSourceCode.showTree(tree1)(ctx) + implicit val c: Context = ctx + val tree1 = + if (ctx.settings.YshowRawQuoteTrees.value) tree + else (new TreeCleaner).transform(tree) + new TastyImpl(ctx).showSourceCode.showTree(tree1) } withTree(expr, show, settings) } def withTree[T](expr: Expr[_], f: (Tree, Context) => T, settings: Toolbox.Settings): T = { - val ctx = setColor(setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)._2.fresh, settings) + val ctx = setToolboxSettings(setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)._2.fresh, settings) var output: Option[T] = None def registerTree(tree: tpd.Tree)(ctx: Context): Unit = { @@ -79,9 +82,10 @@ class QuoteDriver extends Driver { ictx } - private def setColor(ctx: FreshContext, settings: Toolbox.Settings): FreshContext = + private def setToolboxSettings(ctx: FreshContext, settings: Toolbox.Settings): ctx.type = { ctx.setSetting(ctx.settings.color, if (settings.color) "always" else "never") - + ctx.setSetting(ctx.settings.YshowRawQuoteTrees, settings.showRawTree) + } } object QuoteDriver {