Skip to content

Commit 1aa0b22

Browse files
committed
Remove Toolbox.Default
It is impossible ensure that the correct classloader is used.
1 parent d0b5bf3 commit 1aa0b22

File tree

77 files changed

+41
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+41
-103
lines changed

compiler/test-resources/repl/i6007

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
scala> import quoted.Toolbox.Default._
1+
scala> implicit def toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
2+
def toolbox: quoted.Toolbox
23
scala> val v = '{ (if true then Some(1) else None).map(v => v+1) }
34
val v: quoted.Expr[Option[Int]] = Expr(<pickled tasty>)
45
scala> v.show

library/src/scala/quoted/Toolbox.scala

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

33
import scala.annotation.implicitNotFound
44

5-
@implicitNotFound("Could not find implicit quoted.Toolbox.\n\nDefault toolbox can be instantiated with:\n `implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make`\n\nIf only needed once it can also be imported with:\n `import scala.quoted.Toolbox.Default._`")
5+
@implicitNotFound("Could not find implicit quoted.Toolbox.\n\nDefault toolbox can be instantiated with:\n `implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make`\n\n")
66
trait Toolbox {
77
def run[T](expr: Expr[T]): T
88
def show[T](expr: Expr[T]): String
@@ -11,11 +11,6 @@ trait Toolbox {
1111

1212
object Toolbox {
1313

14-
object Default {
15-
// TODO remove? It may be better to only have one way to instantiate the toolbox
16-
implicit def make(implicit settings: Settings): Toolbox = Toolbox.make
17-
}
18-
1914
/** Create a new instance of the toolbox.
2015
*
2116
* This instance of the toolbox tries to recover the classloader of the application based on

tests/neg-with-compiler/i5941/macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object Lens {
1515
def impl[S: Type, T: Type](getter: Expr[S => T])(implicit refl: Reflection): Expr[Lens[S, T]] = {
1616
import refl._
1717
import util._
18-
import quoted.Toolbox.Default._
18+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
1919

2020
// obj.copy(field = value)
2121
def setterBody(obj: Expr[S], value: Expr[T], field: String): Expr[S] =

tests/neg-with-compiler/quote-run-in-macro-1/quoted_1.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import scala.quoted._
22
import scala.quoted.autolift._
33

4-
import scala.quoted.Toolbox.Default._
5-
64
object Macros {
5+
6+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
7+
78
inline def foo(i: => Int): Int = ${ fooImpl('i) }
89
def fooImpl(i: Expr[Int]): Expr[Int] = {
910
val y: Int = i.run

tests/neg-with-compiler/quote-run-in-macro-2/quoted_1.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import scala.quoted._
22
import scala.quoted.autolift._
3-
import scala.quoted.Toolbox.Default._
43

54
object Macros {
5+
66
inline def foo(i: => Int): Int = ${ fooImpl('i) }
77
def fooImpl(i: Expr[Int]): Expr[Int] = {
8+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
89
val y: Int = i.run
910
y
1011
}

tests/neg/tasty-string-interpolator-position-a/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import scala.quoted._
22
import scala.tasty.Reflection
33
import scala.language.implicitConversions
44
import scala.quoted.Exprs.LiftedExpr
5-
import scala.quoted.Toolbox.Default._
65

76
object Macro {
87

@@ -14,6 +13,7 @@ object FIntepolator {
1413

1514
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
1615
import reflect._
16+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
1717
error("there are no parts", strCtxExpr.unseal.underlyingArgument.pos)
1818
'{ ($strCtxExpr).s($argsExpr: _*) }
1919
}

tests/neg/tasty-string-interpolator-position-b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import scala.quoted._
22
import scala.tasty.Reflection
33
import scala.language.implicitConversions
44
import scala.quoted.Exprs.LiftedExpr
5-
import scala.quoted.Toolbox.Default._
65

76
object Macro {
87

@@ -11,6 +10,7 @@ object Macro {
1110
}
1211

1312
object FIntepolator {
13+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
1414

1515
def apply(strCtxExpr: Expr[StringContext], argsExpr: Expr[Seq[Any]])(implicit reflect: Reflection): Expr[String] = {
1616
import reflect._

tests/pos-with-compiler/quote-0.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import scala.quoted._
22
import scala.quoted.autolift._
33

4-
import scala.quoted.Toolbox.Default._
5-
64
object Macros {
75

86

@@ -41,5 +39,7 @@ class Test {
4139
${ powerCode(3, '{math.sqrt(2.0)}) }
4240
}
4341

42+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
43+
4444
program.run
4545
}

tests/pos-with-compiler/quote-assert/quoted_2.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.quoted.Toolbox.Default._
1+
22
import scala.quoted._
33
import Macros._
44

@@ -15,5 +15,7 @@ object Test {
1515
${ assertImpl('{x != 0}) }
1616
}
1717

18+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
19+
1820
program.run
1921
}

0 commit comments

Comments
 (0)