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
}

tests/run-with-compiler/i3823-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {
54
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
65
val z: $t = $x
76
}
7+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
88
println(f('{2})(Type.IntTag).show)
99
}
1010
}

tests/run-with-compiler/i3823-c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {
54
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
65
val z = $x
76
}
7+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
88
println(f('{2})(Type.IntTag).show)
99
}
1010
}

tests/run-with-compiler/i3823.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {
54
def f[T: Type](x: Expr[T])(t: Type[T]) = '{
65
val z: $t = $x
76
}
7+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
88
println(f('{2})('[Int]).show)
99
}
1010
}

tests/run-with-compiler/i3847-b.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
import scala.reflect.ClassTag
43

@@ -14,6 +13,8 @@ object Arrays {
1413
}
1514

1615
object Test {
16+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
17+
1718
def main(args: Array[String]): Unit = {
1819
import Arrays._
1920
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}

tests/run-with-compiler/i3847.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
import scala.reflect.ClassTag
43

@@ -18,6 +17,7 @@ object Test {
1817
import Arrays._
1918
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}
2019
val arr: Expr[Array[Int]] = Array[Int](1, 2, 3).toExpr
20+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
2121
println(arr.show)
2222
}
2323
}

tests/run-with-compiler/i3876-b.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {

tests/run-with-compiler/i3876-c.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {

tests/run-with-compiler/i3876-d.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {

tests/run-with-compiler/i3876.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {

tests/run-with-compiler/i3946.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32
object Test {
43
def main(args: Array[String]): Unit = {

tests/run-with-compiler/i3947.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947b.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947b2.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947b3.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947c.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947d.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947d2.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947e.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947f.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947g.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947i.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i3947j.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
import scala.quoted._
3-
import scala.quoted.Toolbox.Default._
43

54
object Test {
65

tests/run-with-compiler/i4044a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
2-
import scala.quoted.Toolbox.Default._
32

43
class Foo {
54
def foo: Unit = {
5+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
66
val e: Expr[Int] = '{3}
77
val q = '{ ${ '{ $e } } }
88
println(q.show)

tests/run-with-compiler/i4044b.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import scala.quoted._
22

3-
import scala.quoted.Toolbox.Default._
4-
53
sealed abstract class VarRef[T] {
64
def update(expr: Expr[T]): Expr[Unit]
75
def expr: Expr[T]
@@ -22,6 +20,7 @@ object VarRef {
2220

2321
object Test {
2422
def main(args: Array[String]): Unit = {
23+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
2524
val q = VarRef('{4})(varRef => '{ ${varRef.update('{3})}; ${varRef.expr} })
2625
println(q.show)
2726
}

tests/run-with-compiler/i4044c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
2-
import scala.quoted.Toolbox.Default._
32

43
class Foo {
54
def foo: Unit = {
5+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
66
val q = '{ ${ '{ ${ '{ 5 } } } } }
77
println(q.show)
88
}

tests/run-with-compiler/i4044d.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
2-
import scala.quoted.Toolbox.Default._
32

43
class Foo {
54
def foo: Unit = {
5+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
66
val a: Expr[Int] = '{3}
77
val q: Expr[Int] = '{
88
val b = 3

tests/run-with-compiler/i4044e.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
2-
import scala.quoted.Toolbox.Default._
32

43
class Foo {
54
def foo: Unit = {
5+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
66
val e: Expr[Int] = '{3}
77
val f: Expr[Int] = '{5}
88
val t: Type[Int] = '[Int]

tests/run-with-compiler/i4044f.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import scala.quoted._
2-
import scala.quoted.Toolbox.Default._
32

43
class Foo {
54
def foo: Unit = {
5+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
66
val e: Expr[Int] = '{3}
77
val f: Expr[Int] = '{5}
88
def foo(x: Expr[Int], y: Expr[Int]): Expr[Int] = '{ $x + $y }

tests/run-with-compiler/i4350.scala

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

32
import scala.quoted.Type
43

tests/run-with-compiler/i4591.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.quoted.Toolbox.Default._
21
import scala.quoted._
32

43
object Test {
@@ -9,6 +8,7 @@ object Test {
98
}
109

1110
def main(args: Array[String]): Unit = {
11+
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make
1212
foo('{Option(9)}).run
1313
}
1414

0 commit comments

Comments
 (0)