@@ -2,7 +2,7 @@ package dotty.tools.dotc.quoted
22
33import dotty .tools .dotc .ast .tpd
44import dotty .tools .dotc .Driver
5- import dotty .tools .dotc .core .Contexts .{Context , ContextBase }
5+ import dotty .tools .dotc .core .Contexts .{Context , ContextBase , FreshContext }
66import dotty .tools .dotc .tastyreflect .TastyImpl
77import dotty .tools .io .{AbstractFile , Directory , PlainDirectory , VirtualDirectory }
88import dotty .tools .repl .AbstractFileClassLoader
@@ -27,7 +27,7 @@ class QuoteDriver extends Driver {
2727 }
2828
2929 val (_, ctx0 : Context ) = setup(settings.compilerArgs.toArray :+ " dummy.scala" , initCtx.fresh)
30- val ctx = ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir)
30+ val ctx = setColor( ctx0.fresh.setSetting(ctx0.settings.outputDir, outDir), settings )
3131
3232 val driver = new QuoteCompiler
3333 driver.newRun(ctx).compileExpr(expr)
@@ -50,7 +50,7 @@ class QuoteDriver extends Driver {
5050 }
5151
5252 def withTree [T ](expr : Expr [_], f : (Tree , Context ) => T , settings : Toolbox .Settings ): T = {
53- val (_, ctx : Context ) = setup(settings.compilerArgs.toArray :+ " dummy.scala" , initCtx.fresh)
53+ val ctx = setColor( setup(settings.compilerArgs.toArray :+ " dummy.scala" , initCtx.fresh)._2.fresh, settings )
5454
5555 var output : Option [T ] = None
5656 def registerTree (tree : tpd.Tree )(ctx : Context ): Unit = {
@@ -79,6 +79,9 @@ class QuoteDriver extends Driver {
7979 ictx
8080 }
8181
82+ private def setColor (ctx : FreshContext , settings : Toolbox .Settings ): FreshContext =
83+ ctx.setSetting(ctx.settings.color, if (settings.color) " always" else " never" )
84+
8285}
8386
8487object QuoteDriver {
0 commit comments