Skip to content

Commit 8fdcff2

Browse files
committed
Simplify Runners
1 parent 281c8e6 commit 8fdcff2

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ import scala.runtime.quoted._
55

66
/** Default runners for quoted expressions */
77
object Runners {
8-
implicit def runner[T]: Runner[T] = (expr: Expr[T]) => new QuoteDriver().run(expr)
9-
implicit def show[T]: Show[T] = (expr: Expr[T]) => new QuoteDriver().show(expr)
8+
implicit def runner[T]: Runner[T] = new Runner[T] {
9+
10+
def run(expr: Expr[T]): T =
11+
new QuoteDriver().run(expr)
12+
13+
def show(expr: Expr[T]): String =
14+
new QuoteDriver().show(expr)
15+
}
1016
}

library/src/scala/quoted/Expr.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package scala.quoted
22

3-
import scala.runtime.quoted.{Runner, Show}
3+
import scala.runtime.quoted.Runner
44

55
abstract class Expr[T] extends Quoted {
66
final def unary_~ : T = throw new Error("~ should have been compiled away")
77
final def run(implicit runner: Runner[T]): T = runner.run(this)
8-
final def show(implicit runner: Show[T]): String = runner.run(this)
8+
final def show(implicit runner: Runner[T]): String = runner.show(this)
99
}
1010

1111
object Expr {

library/src/scala/runtime/quoted/Runner.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import scala.quoted.Expr
66
@implicitNotFound("Could not find implicit Runner. Default runner can must be imported with `import dotty.tools.dotc.quoted.Runners._`")
77
trait Runner[T] {
88
def run(expr: Expr[T]): T
9+
def show(expr: Expr[T]): String
910
}

library/src/scala/runtime/quoted/Show.scala

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)