Skip to content

Commit f2a4126

Browse files
committed
Add settings object to the Runners.run
1 parent c653b1a commit f2a4126

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import java.nio.charset.StandardCharsets
1313

1414
class QuoteDriver extends Driver {
1515

16-
def run[T](expr: Expr[T], optimise: Boolean): T = {
16+
def run[T](expr: Expr[T], settings: Runners.RunSettings): T = {
1717
val ctx: Context = initCtx.fresh
18-
ctx.settings.optimise.update(optimise)(ctx)
18+
ctx.settings.optimise.update(settings.optimise)(ctx)
1919

2020
val outDir = new VirtualDirectory("(memory)", None)
2121

compiler/src/dotty/tools/dotc/quoted/Runners.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ object Runners {
1313

1414
implicit def runner[T]: Runner[T] = new Runner[T] {
1515

16-
def run(expr: Expr[T]): T = Runners.run(expr, optimise = false)
16+
def run(expr: Expr[T]): T = Runners.run(expr, RunSettings())
1717

1818
def show(expr: Expr[T]): String = expr match {
1919
case expr: ConstantExpr[T] =>
@@ -25,8 +25,12 @@ object Runners {
2525
}
2626
}
2727

28-
def run[T](expr: Expr[T], optimise: Boolean): T = expr match {
28+
def run[T](expr: Expr[T], settings: RunSettings): T = expr match {
2929
case expr: ConstantExpr[T] => expr.value
30-
case _ => new QuoteDriver().run(expr, optimise)
30+
case _ => new QuoteDriver().run(expr, settings)
3131
}
32+
33+
case class RunSettings(
34+
optimise: Boolean = false
35+
)
3236
}

tests/run-with-compiler/quote-run-optimise.scala renamed to tests/run-with-compiler/quote-run-with-settings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ object Test {
1111
2 + a
1212
}
1313
println(expr.show)
14-
println(run(expr.run, optimise = true))
14+
println(run(expr.run, RunSettings(optimise = true)))
1515
println(expr.run)
1616
}
1717
}

0 commit comments

Comments
 (0)