Skip to content

Commit 488117c

Browse files
committed
Use delegates for Toolbox
1 parent 7769c51 commit 488117c

File tree

85 files changed

+89
-86
lines changed

Some content is hidden

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

85 files changed

+89
-86
lines changed

docs/docs/reference/metaprogramming/staging.md

Lines changed: 3 additions & 1 deletion

library/src/scala/quoted/staging/Toolbox.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package staging
33

44
import scala.annotation.implicitNotFound
55

6-
@implicitNotFound("Could not find implicit scala.quoted.staging.Toolbox.\n\nDefault toolbox can be instantiated with:\n `implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)`\n\n")
6+
@implicitNotFound("Could not find implicit scala.quoted.staging.Toolbox.\n\nDefault toolbox can be instantiated with:\n `delegate for scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)`\n\n")
77
trait Toolbox {
88
def run[T](expr: QuoteContext => Expr[T]): T
99
}
@@ -14,7 +14,8 @@ object Toolbox {
1414
*
1515
* Usuage:
1616
* ```
17-
* implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
17+
* import scala.quoted.staging._
18+
* delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
1819
* ```
1920
*
2021
* @param appClassloader classloader of the application that generated the quotes

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Macros {
55

66
inline def foo(i: => Int): Int = ${ fooImpl('i) }
77
def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = {
8-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
8+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
99
val y: Int = run(i)
1010
y
1111
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import given scala.quoted.autolift._
44

55
object Macros {
66

7-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
7+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
88
inline def foo(i: => Int): Int = ${ fooImpl('i) }
99
def fooImpl(i: Expr[Int]) given QuoteContext: Expr[Int] = {
1010
val y: Int = run(i)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ object Macros {
2525

2626
class Test {
2727

28-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
28+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
2929

3030
run {
3131
val program = '{

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ object Test {
1717
${ assertImpl('{x != 0}) }
1818
}
1919

20-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
20+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
2121
run(program)
2222
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22
import scala.quoted.staging._
33
object Test {
4-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
4+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
55
def main(args: Array[String]): Unit = withQuoteContext {
66
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
77
val z: $t = $x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22
import scala.quoted.staging._
33
object Test {
4-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
4+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
55
def main(args: Array[String]): Unit = withQuoteContext {
66
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
77
val z = $x

tests/run-with-compiler/i3823.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22
import scala.quoted.staging._
33
object Test {
4-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
4+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
55
def main(args: Array[String]): Unit = withQuoteContext {
66
def f[T: Type](x: Expr[T])(t: Type[T]) = '{
77
val z: $t = $x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Arrays {
1414
}
1515

1616
object Test {
17-
implicit val toolbox: scala.quoted.staging.Toolbox = scala.quoted.staging.Toolbox.make(getClass.getClassLoader)
17+
delegate for Toolbox = Toolbox.make(getClass.getClassLoader)
1818
def main(args: Array[String]): Unit = withQuoteContext {
1919
import Arrays._
2020
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}

0 commit comments

Comments
 (0)