Skip to content

Rename quoted.Runner to quoted.Toolbox #4040

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
Feb 27, 2018
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/quoted/QuoteDriver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import scala.quoted.Expr

import java.net.URLClassLoader

import Runners.{Settings, Run, Show}
import Toolbox.{Settings, Run, Show}

class QuoteDriver extends Driver {
import tpd._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ import scala.quoted.Exprs.ValueExpr
import scala.runtime.quoted._

/** Default runners for quoted expressions */
object Runners {
object Toolbox {
import tpd._

type Run
type Show

implicit def runner[T]: Runner[T] = new Runner[T] {
implicit def toolbox[T]: Toolbox[T] = new Toolbox[T] {

def run(expr: Expr[T]): T = Runners.run(expr, Settings.run())
def run(expr: Expr[T]): T = Toolbox.run(expr, Settings.run())

def show(expr: Expr[T]): String = Runners.show(expr, Settings.show())
def show(expr: Expr[T]): String = Toolbox.show(expr, Settings.show())

def toConstantOpt(expr: Expr[T]): Option[T] = {
def toConstantOpt(tree: Tree): Option[T] = tree match {
Expand Down
4 changes: 2 additions & 2 deletions library/src/scala/quoted/Constant.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scala.quoted

import scala.runtime.quoted.Runner
import scala.runtime.quoted.Toolbox

object Constant {
def unapply[T](expr: Expr[T])(implicit runner: Runner[T]): Option[T] = runner.toConstantOpt(expr)
def unapply[T](expr: Expr[T])(implicit runner: Toolbox[T]): Option[T] = runner.toConstantOpt(expr)
}
6 changes: 3 additions & 3 deletions library/src/scala/quoted/Expr.scala
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package scala.quoted

import scala.runtime.quoted.Runner
import scala.runtime.quoted.Toolbox
import scala.runtime.quoted.Unpickler.Pickled

sealed abstract class Expr[T] {
final def unary_~ : T = throw new Error("~ should have been compiled away")
final def run(implicit runner: Runner[T]): T = runner.run(this)
final def show(implicit runner: Runner[T]): String = runner.show(this)
final def run(implicit toolbox: Toolbox[T]): T = toolbox.run(this)
final def show(implicit toolbox: Toolbox[T]): String = toolbox.show(this)
}

object Expr {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package scala.runtime.quoted
import scala.annotation.implicitNotFound
import scala.quoted.Expr

@implicitNotFound("Could not find implicit Runner. Default runner can be imported with `import dotty.tools.dotc.quoted.Runners._`")
trait Runner[T] {
@implicitNotFound("Could not find implicit Toolbox. Default runner can be imported with `import dotty.tools.dotc.quoted.Toolbox._`")
trait Toolbox[T] {
def run(expr: Expr[T]): T
def show(expr: Expr[T]): String
def toConstantOpt(expr: Expr[T]): Option[T]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import scala.quoted._

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

object Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/pending/run-with-compiler/quote-run-large.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted.TastyExpr

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/quote-0.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scala.quoted._
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

class Test {

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/quote-assert/quoted_2.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners.runner
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
import Macros._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3823-b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3823-c.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3823.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3876-b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3876-c.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3876-d.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3876.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/i3946.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._
import scala.quoted._
object Test {
def main(args: Array[String]): Unit = {
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-lib.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import scala.quoted._
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import liftable.Units._
import liftable.Lets._
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-2.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-b.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-c.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-constants.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-staged-interpreter.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import scala.quoted._
import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

enum Exp {
case Num(n: Int)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run-with-settings.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import java.nio.file.{Files, Paths}

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down
2 changes: 1 addition & 1 deletion tests/run-with-compiler/quote-run.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

import dotty.tools.dotc.quoted.Runners._
import dotty.tools.dotc.quoted.Toolbox._

import scala.quoted._

Expand Down