Skip to content

Commit ab2541a

Browse files
committed
Rename withNewQuoteContext to withQuoteContext
1 parent 9dc1087 commit ab2541a

Some content is hidden

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

44 files changed

+60
-60
lines changed

compiler/test-resources/repl-macros/i6007

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ scala> implicit def toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(ge
22
def toolbox: quoted.Toolbox
33
scala> val v = '{ (if true then Some(1) else None).map(v => v+1) }
44
val v: quoted.Expr[Option[Int]] = Expr(<pickled tasty>)
5-
scala> scala.quoted.withNewQuoteContext(v.show)
5+
scala> scala.quoted.withQuoteContext(v.show)
66
val res0: String = (if (true) scala.Some.apply[scala.Int](1) else scala.None).map[scala.Int](((v: scala.Int) => v.+(1)))
77
scala> scala.quoted.run(v)
88
val res1: Option[Int] = Some(2)

docs/docs/reference/metaprogramming/staging.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ to be executed at a later stage. To run that code, there is another method
6161
in class `Expr` called `run`. Note that `$` and `run` both map from `Expr[T]`
6262
to `T` but only `$` is subject to the PCP, whereas `run` is just a normal method.
6363
Run provides a `QuoteContext` that can be used to show the expression in the scope of `run`.
64-
On the other hand `withNewQuoteContext` provides a `QuoteContext` without evauating the expression.
64+
On the other hand `withQuoteContext` provides a `QuoteContext` without evauating the expression.
6565

6666
```scala
6767
package scala.quoted
6868

6969
def run[T](expr: given QuoteContext => Expr[T]) given (toolbox: Toolbox): T = ...
7070

71-
def withNewQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = ...
71+
def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = ...
7272
```
7373

7474
## Example

library/src-3.x/scala/quoted/package.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ package object quoted {
2424
*
2525
* Usage:
2626
* ```
27-
* val e: T = withNewQuoteContext { // (given qctx: QuoteContext) =>
27+
* val e: T = withQuoteContext { // (given qctx: QuoteContext) =>
2828
* thunk
2929
* }
3030
* ```
3131
* where `thunk: T`
3232
*
3333
* This method shoul not be called in a context where there is already has a QuoteContext.
3434
*/
35-
def withNewQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = {
35+
def withQuoteContext[T](thunk: given QuoteContext => T) given (toolbox: Toolbox): T = {
3636
var result: T = NoResult.asInstanceOf[T]
3737
def dummyRun given QuoteContext: Expr[Unit] = {
3838
result = thunk

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
object Test {
33
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
4-
def main(args: Array[String]): Unit = withNewQuoteContext {
4+
def main(args: Array[String]): Unit = withQuoteContext {
55
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
66
val z: $t = $x
77
}

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
object Test {
33
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
4-
def main(args: Array[String]): Unit = withNewQuoteContext {
4+
def main(args: Array[String]): Unit = withQuoteContext {
55
def f[T](x: Expr[T])(implicit t: Type[T]) = '{
66
val z = $x
77
}

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
object Test {
33
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
4-
def main(args: Array[String]): Unit = withNewQuoteContext {
4+
def main(args: Array[String]): Unit = withQuoteContext {
55
def f[T: Type](x: Expr[T])(t: Type[T]) = '{
66
val z: $t = $x
77
}

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
object Test {
1616
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
17-
def main(args: Array[String]): Unit = withNewQuoteContext {
17+
def main(args: Array[String]): Unit = withQuoteContext {
1818
import Arrays._
1919
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}
2020
val arr: Expr[Array[List[Int]]] = Array[List[Int]](List(1, 2, 3)).toExpr

tests/run-with-compiler/i3847.scala

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

1515
object Test {
1616
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(this.getClass.getClassLoader)
17-
def main(args: Array[String]): Unit = withNewQuoteContext {
17+
def main(args: Array[String]): Unit = withQuoteContext {
1818
import Arrays._
1919
implicit val ct: Expr[ClassTag[Int]] = '{ClassTag.Int}
2020
val arr: Expr[Array[Int]] = Array[Int](1, 2, 3).toExpr

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ object Test {
1111
}
1212

1313
println(run(f2(x)))
14-
println(withNewQuoteContext(f2(x).show))
14+
println(withQuoteContext(f2(x).show))
1515
}
1616
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ object Test {
1111
}
1212

1313
println(run(f3(x)))
14-
println(withNewQuoteContext(f3(x).show)) // TODO improve printer
14+
println(withQuoteContext(f3(x).show)) // TODO improve printer
1515
}
1616
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
inlineLambda
1010
}
1111
println(run(f4(x)))
12-
println(withNewQuoteContext(f4(x).show))
12+
println(withQuoteContext(f4(x).show))
1313
}
1414

1515
inline def inlineLambda <: Int => Int = x => x + x

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object Test {
99
inlineLambda
1010
}
1111
println(run(f4(x)))
12-
println(withNewQuoteContext(f4(x).show))
12+
println(withQuoteContext(f4(x).show))
1313
}
1414

1515
inline def inlineLambda <: Int => Int = x => x + x

tests/run-with-compiler/i3876.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ object Test {
88
val f: Expr[Int => Int] = '{ (x: Int) => x + x }
99

1010
println(run(f(x)))
11-
println(withNewQuoteContext(f(x).show))
11+
println(withQuoteContext(f(x).show))
1212
}
1313
}

tests/run-with-compiler/i3946.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object Test {
33
def main(args: Array[String]): Unit = {
44
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
55
val u: Expr[Unit] = '{}
6-
println(withNewQuoteContext(u.show))
6+
println(withQuoteContext(u.show))
77
println(run(u))
88
}
99
}

tests/run-with-compiler/i4044a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Foo {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val e: Expr[Int] = '{3}
77
val q = '{ ${ '{ $e } } }
8-
println(withNewQuoteContext(q.show))
8+
println(withQuoteContext(q.show))
99
}
1010
}
1111

tests/run-with-compiler/i4044b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ object Test {
2222
def main(args: Array[String]): Unit = {
2323
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
2424
val q = VarRef('{4})(varRef => '{ ${varRef.update('{3})}; ${varRef.expr} })
25-
println(withNewQuoteContext(q.show))
25+
println(withQuoteContext(q.show))
2626
}
2727
}

tests/run-with-compiler/i4044c.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Foo {
44
def foo: Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = '{ ${ '{ ${ '{ 5 } } } } }
7-
println(withNewQuoteContext(q.show))
7+
println(withQuoteContext(q.show))
88
}
99
}
1010

tests/run-with-compiler/i4044e.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Foo {
77
val f: Expr[Int] = '{5}
88
val t: Type[Int] = '[Int]
99
val q = '{ ${ '{ ($e + $f).asInstanceOf[$t] } } }
10-
println(withNewQuoteContext(q.show))
10+
println(withQuoteContext(q.show))
1111
}
1212
}
1313

tests/run-with-compiler/i4044f.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Foo {
1414
foo('{e1 + $u}, '{f1})
1515
}
1616
}
17-
println(withNewQuoteContext(q.show))
17+
println(withQuoteContext(q.show))
1818
}
1919
}
2020

tests/run-with-compiler/i4350.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Foo[T: Type] {
77

88
object Test {
99
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
10-
def main(args: Array[String]): Unit = withNewQuoteContext {
10+
def main(args: Array[String]): Unit = withQuoteContext {
1111
println((new Foo[Object]).q.show)
1212
println((new Foo[String]).q.show)
1313
}

tests/run-with-compiler/i5144.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Test {
88
def f(x: Int): Int = ${eval1('f)}
99
}
1010

11-
def main(args: Array[String]): Unit = withNewQuoteContext {
11+
def main(args: Array[String]): Unit = withQuoteContext {
1212
val p = peval1()
1313
println(p.show)
1414
}

tests/run-with-compiler/i5152.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Test {
88
lazy val f: Int => Int = ${eval1('{(y: Int) => f(y)})}
99
}
1010

11-
def main(args: Array[String]): Unit = withNewQuoteContext {
11+
def main(args: Array[String]): Unit = withQuoteContext {
1212
val p = peval1()
1313
println(p.show)
1414
}

tests/run-with-compiler/i5161.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ object Test {
2626
val test = Add(Int2(1), Int2(1))
2727
val res = evalTest(test)
2828
println("run : " + run(res))
29-
println("show : " + withNewQuoteContext(res.show))
29+
println("show : " + withQuoteContext(res.show))
3030
}
3131
}

tests/run-with-compiler/i5161b.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ object Test {
99
if (x.isInstanceOf[Some[_]]) Option(1)
1010
else None
1111
}
12-
println("show0 : " + withNewQuoteContext(res.show))
12+
println("show0 : " + withQuoteContext(res.show))
1313
println("run1 : " + run(res))
1414
println("run2 : " + run(res))
15-
println("show3 : " + withNewQuoteContext(res.show))
15+
println("show3 : " + withQuoteContext(res.show))
1616
}
1717
}

tests/run-with-compiler/i5247.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22
object Test {
33
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
4-
def main(args: Array[String]): Unit = withNewQuoteContext {
4+
def main(args: Array[String]): Unit = withQuoteContext {
55
println(foo[Object].show)
66
println(bar[Object].show)
77
}

tests/run-with-compiler/i5965.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ object Test {
88
def main(args: Array[String]): Unit = {
99
'[List]
1010
val list = bound('{List(1, 2, 3)})
11-
println(withNewQuoteContext(list.show))
11+
println(withQuoteContext(list.show))
1212
println(run(list))
1313

1414
val opt = bound('{Option(4)})
15-
println(withNewQuoteContext(opt.show))
15+
println(withQuoteContext(opt.show))
1616
println(run(opt))
1717

1818
val map = bound('{Map(4 -> 1)})
19-
println(withNewQuoteContext(map.show))
19+
println(withQuoteContext(map.show))
2020
println(run(map))
2121
}
2222

tests/run-with-compiler/i5965b.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ object Test {
99

1010
'[List]
1111
val list = bound('{List(1, 2, 3)})
12-
println(withNewQuoteContext(list.show))
12+
println(withQuoteContext(list.show))
1313
println(run(list))
1414

1515
val opt = bound('{Option(4)})
16-
println(withNewQuoteContext(opt.show))
16+
println(withQuoteContext(opt.show))
1717
println(run(opt))
1818

1919
val map = bound('{Map(4 -> 1)})
20-
println(withNewQuoteContext(map.show))
20+
println(withQuoteContext(map.show))
2121
println(run(map))
2222
}
2323

tests/run-with-compiler/i5997.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22
object Test {
33
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
4-
def main(args: Array[String]): Unit = withNewQuoteContext {
4+
def main(args: Array[String]): Unit = withQuoteContext {
55
val v = '{ (if true then Some(1) else None).map(v => v+1) }
66
println(v.show)
77
}

tests/run-with-compiler/quote-function-applied-to.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
object Test {
44
def main(args: Array[String]): Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
6-
def show(expr: Expr[_]): String = withNewQuoteContext(expr.show)
6+
def show(expr: Expr[_]): String = withQuoteContext(expr.show)
77
println(show(('{ () => x(0) }).apply()))
88
println(show(('{ (x1: Int) => x1 }).apply('{x(1)})))
99
println(show(('{ (x1: Int, x2: Int) => x1 + x2 }).apply('{x(1)}, '{x(2)})))

tests/run-with-compiler/quote-macro-in-splice/quoted_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Macros._
33

44
object Test {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
6-
def main(args: Array[String]): Unit = withNewQuoteContext {
6+
def main(args: Array[String]): Unit = withQuoteContext {
77
val x = '{
88
val y = 1
99
${

tests/run-with-compiler/quote-nested-1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ object Test {
44
def main(args: Array[String]): Unit = {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = '{ '{3} }
7-
println(withNewQuoteContext(q.show))
7+
println(withQuoteContext(q.show))
88
}
99
}

tests/run-with-compiler/quote-nested-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ object Test {
99
'{${a}}
1010
}
1111

12-
println(withNewQuoteContext(q.show))
12+
println(withQuoteContext(q.show))
1313
}
1414
}

tests/run-with-compiler/quote-nested-3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ object Test {
1414
x
1515
}
1616

17-
println(withNewQuoteContext(q.show))
17+
println(withQuoteContext(q.show))
1818
}
1919
}

tests/run-with-compiler/quote-nested-4.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ object Test {
99
t
1010
}
1111

12-
println(withNewQuoteContext(q.show))
12+
println(withQuoteContext(q.show))
1313
}
1414
}

tests/run-with-compiler/quote-nested-5.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ object Test {
1212

1313
}
1414

15-
println(withNewQuoteContext(q.show))
15+
println(withQuoteContext(q.show))
1616
}
1717
}

tests/run-with-compiler/quote-owners.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Test {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
66
val q = f
77
println(run(q))
8-
println(withNewQuoteContext(q.show))
8+
println(withQuoteContext(q.show))
99
}
1010

1111
def f: Expr[Int] = '{

tests/run-with-compiler/quote-run-2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33

44
object Test {
55
implicit val toolbox: scala.quoted.Toolbox = scala.quoted.Toolbox.make(getClass.getClassLoader)
6-
def main(args: Array[String]): Unit = withNewQuoteContext {
6+
def main(args: Array[String]): Unit = withQuoteContext {
77
def powerCode(n: Int, x: Expr[Double]): Expr[Double] =
88
if (n == 0) '{1.0}
99
else if (n == 1) x

tests/run-with-compiler/quote-run-constants.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ object Test {
2323

2424
println("======")
2525

26-
withNewQuoteContext {
26+
withQuoteContext {
2727
def show[T](expr: Expr[T]): Unit = println(expr.show)
2828

2929
show(true)

tests/run-with-compiler/quote-run-staged-interpreter.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ object Test {
3434
val res1 = '{ (x: Int) => ${compile(exp, Map("x" -> 'x), false)} }
3535

3636

37-
println(withNewQuoteContext(res1.show))
37+
println(withQuoteContext(res1.show))
3838

3939
val fn = run {
4040
res1
@@ -46,13 +46,13 @@ object Test {
4646
println("---")
4747

4848
val res2 = compile(letExp, Map(), false)
49-
println(withNewQuoteContext(res2.show))
49+
println(withQuoteContext(res2.show))
5050
println(run(res2))
5151

5252
println("---")
5353

5454
val res3 = compile(letExp, Map(), true)
55-
println(withNewQuoteContext(res3.show))
55+
println(withQuoteContext(res3.show))
5656
println(run(res3))
5757
}
5858
}

0 commit comments

Comments
 (0)