Skip to content

Set ThrowingReporter in the QuotedDriver #6321

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 1 commit into from
Apr 16, 2019
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
6 changes: 4 additions & 2 deletions compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import dotty.tools.dotc.core.Contexts.{Context, ContextBase, FreshContext}
import dotty.tools.dotc.tastyreflect.ReflectionImpl
import dotty.tools.io.{AbstractFile, Directory, PlainDirectory, VirtualDirectory}
import dotty.tools.repl.AbstractFileClassLoader

import dotty.tools.dotc.reporting._
import scala.quoted.{Expr, Type}
import scala.quoted.Toolbox
import java.net.URLClassLoader
Expand Down Expand Up @@ -61,7 +61,6 @@ class QuoteDriver(appClassloader: ClassLoader) extends Driver {
def show(tpe: Type[_], settings: Toolbox.Settings): String =
withTypeTree(tpe, doShow, settings)


def withTree[T](expr: Expr[_], f: (Tree, Context) => T, settings: Toolbox.Settings): T = {
val ctx = setToolboxSettings(setup(settings.compilerArgs.toArray :+ "dummy.scala", initCtx.fresh)._2.fresh, settings)

Expand Down Expand Up @@ -95,6 +94,9 @@ class QuoteDriver(appClassloader: ClassLoader) extends Driver {
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)
// An error in the generated code is a bug in the compiler
// Setting the throwing reporter however will report any exception
ctx.setReporter(new ThrowingReporter(ctx.reporter))
}
}

Expand Down