Skip to content

Commit c4e5535

Browse files
committed
Rename Expr.valueOr{Error => Throw}
1 parent 8b35b67 commit c4e5535

File tree

49 files changed

+119
-110
lines changed

Some content is hidden

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

49 files changed

+119
-110
lines changed

docs/docs/reference/metaprogramming/macros.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ either a constant or is a parameter that will be a constant when instantiated. T
454454
aspect is also important for macro expansion.
455455

456456
To get values out of expressions containing constants `Expr` provides the method
457-
`value` (or `valueOrError`). This will convert the `Expr[T]` into a `Some[T]` (or `T`) when the
457+
`value` (or `valueOrThrow`). This will convert the `Expr[T]` into a `Some[T]` (or `T`) when the
458458
expression contains value. Otherwise it will retrun `None` (or emit an error).
459459
To avoid having incidental val bindings generated by the inlining of the `def`
460460
it is recommended to use an inline parameter. To illustrate this, consider an
@@ -628,7 +628,7 @@ transparent inline def defaultOf(inline str: String) =
628628
${ defaultOfImpl('str) }
629629

630630
def defaultOfImpl(strExpr: Expr[String])(using Quotes): Expr[Any] =
631-
strExpr.valueOrError match
631+
strExpr.valueOrThrow match
632632
case "int" => '{1}
633633
case "string" => '{"a"}
634634

library/src/scala/quoted/Expr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ object Expr {
4646
* // value: T
4747
* ```
4848
*
49-
* To directly get the value of an expression `expr: Expr[T]` consider using `expr.value`/`expr.valueOrError` instead.
49+
* To directly get the value of an expression `expr: Expr[T]` consider using `expr.value`/`expr.valueOrThrow` instead.
5050
* @syntax markdown
5151
*/
5252
def unapply[T](x: Expr[T])(using FromExpr[T])(using Quotes): Option[T] =

library/src/scala/quoted/Exprs.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Exprs:
1414
* ...
1515
* }
1616
* ```
17-
* To directly get the value of all expressions in a sequence `exprs: Seq[Expr[T]]` consider using `exprs.map(_.value)`/`exprs.map(_.valueOrError)` instead.
17+
* To directly get the value of all expressions in a sequence `exprs: Seq[Expr[T]]` consider using `exprs.map(_.value)`/`exprs.map(_.valueOrThrow)` instead.
1818
*/
1919
def unapply[T](exprs: Seq[Expr[T]])(using FromExpr[T])(using Quotes): Option[Seq[T]] =
2020
val builder = Seq.newBuilder[T]

library/src/scala/quoted/Quotes.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
5353
* Emits an error and throws if the expression does not represent a value or possibly contains side effects.
5454
* Otherwise returns the value.
5555
*/
56-
def valueOrError(using FromExpr[T]): T =
56+
@deprecated("Use valueOrThrow", "3.0.0")
57+
def valueOrError(using e: FromExpr[T]): T =
58+
valueOrThrow
59+
60+
/** Return the value of this expression.
61+
*
62+
* Emits an error and throws if the expression does not represent a value or possibly contains side effects.
63+
* Otherwise returns the value.
64+
*/
65+
def valueOrThrow(using FromExpr[T]): T =
5766
val fromExpr = summon[FromExpr[T]]
5867
def reportError =
5968
val msg = s"Expected a known value. \n\nThe value of: ${self.show}\ncould not be extracted using $fromExpr"

tests/bench/power-macro/PowerMacro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object PowerMacro {
55
inline def power(inline n: Long, x: Double) = ${ powerCode('n, 'x) }
66

77
def powerCode(n: Expr[Long], x: Expr[Double])(using Quotes): Expr[Double] =
8-
powerCode(n.valueOrError, x)
8+
powerCode(n.valueOrThrow, x)
99

1010
def powerCode(n: Long, x: Expr[Double])(using Quotes): Expr[Double] =
1111
if (n == 0) '{1.0}

tests/neg-macros/inline-macro-staged-interpreter/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object E {
66

77
inline def eval[T](inline x: E[T]): T = ${ impl('x) }
88

9-
def impl[T: Type](x: Expr[E[T]]) (using Quotes): Expr[T] = x.valueOrError.lift
9+
def impl[T: Type](x: Expr[E[T]]) (using Quotes): Expr[T] = x.valueOrThrow.lift
1010

1111
implicit def ev1[T: Type]: FromExpr[E[T]] = new FromExpr {
1212
def unapply(x: Expr[E[T]])(using Quotes) = x match {

tests/neg-macros/inline-option/Macro_1.scala

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

44
object Macro {
5-
def impl(opt: Expr[Option[Int]]) (using Quotes): Expr[Int] = opt.valueOrError match {
5+
def impl(opt: Expr[Option[Int]]) (using Quotes): Expr[Int] = opt.valueOrThrow match {
66
case Some(i) => Expr(i)
77
case None => '{-1}
88
}

tests/neg-macros/inline-tuples-1/Macro_1.scala

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
import scala.quoted.*
33

44
object Macros {
5-
def tup1(tup: Expr[Tuple1[Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
6-
def tup2(tup: Expr[Tuple2[Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
7-
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
8-
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
9-
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
10-
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
11-
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
12-
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
13-
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
14-
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
15-
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
16-
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
17-
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
18-
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
19-
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
20-
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
21-
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
22-
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
23-
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
24-
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
25-
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
26-
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
5+
def tup1(tup: Expr[Tuple1[Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
6+
def tup2(tup: Expr[Tuple2[Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
7+
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
8+
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
9+
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
10+
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
11+
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
12+
def tup8(tup: Expr[Tuple8[Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
13+
def tup9(tup: Expr[Tuple9[Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
14+
def tup10(tup: Expr[Tuple10[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
15+
def tup11(tup: Expr[Tuple11[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
16+
def tup12(tup: Expr[Tuple12[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
17+
def tup13(tup: Expr[Tuple13[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
18+
def tup14(tup: Expr[Tuple14[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
19+
def tup15(tup: Expr[Tuple15[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
20+
def tup16(tup: Expr[Tuple16[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
21+
def tup17(tup: Expr[Tuple17[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
22+
def tup18(tup: Expr[Tuple18[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
23+
def tup19(tup: Expr[Tuple19[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
24+
def tup20(tup: Expr[Tuple20[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
25+
def tup21(tup: Expr[Tuple21[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
26+
def tup22(tup: Expr[Tuple22[Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
2727
}

tests/neg-macros/quote-error-2/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import quoted.*
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${ fooImpl('b) }
55
def fooImpl(b: Expr[Boolean])(using Quotes): Expr[Unit] =
6-
'{println(${msg(b.valueOrError)})}
6+
'{println(${msg(b.valueOrThrow)})}
77

88
def msg(b: Boolean)(using Quotes): Expr[String] =
99
if (b) '{"foo(true)"}

tests/neg-macros/quote-error/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import quoted.*
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
55
def fooImpl(b: Expr[Boolean])(using Quotes) : Expr[Unit] =
6-
if (b.valueOrError) '{println("foo(true)")}
6+
if (b.valueOrThrow) '{println("foo(true)")}
77
else { quotes.reflect.report.error("foo cannot be called with false"); '{ ??? } }
88
}

tests/neg-macros/quote-exception/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ import quoted.*
33
object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
55
def fooImpl(b: Expr[Boolean]) (using Quotes): Expr[Unit] =
6-
if (b.valueOrError) '{println("foo(true)")}
6+
if (b.valueOrThrow) '{println("foo(true)")}
77
else ???
88
}

tests/neg-macros/quote-whitebox/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted.*
22

33
object Macros {
44
transparent inline def defaultOf(inline str: String): Any = ${ defaultOfImpl('str) }
5-
def defaultOfImpl(str: Expr[String]) (using Quotes): Expr[Any] = str.valueOrError match {
5+
def defaultOfImpl(str: Expr[String]) (using Quotes): Expr[Any] = str.valueOrThrow match {
66
case "int" => '{1}
77
case "string" => '{"a"}
88
}

tests/neg-macros/reflect-inline/assert_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object api {
55
${ stripImpl('x) }
66

77
private def stripImpl(x: Expr[String])(using Quotes): Expr[String] =
8-
Expr(x.valueOrError.stripMargin)
8+
Expr(x.valueOrThrow.stripMargin)
99

1010
}

tests/pos-macros/i11835/X.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ object X:
88
import quotes.reflect.*
99
println("="*120)
1010
println(b.asTerm)
11-
println(b.valueOrError)
11+
println(b.valueOrThrow)
1212
'{()}

tests/pos-macros/power-macro/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object PowerMacro {
66
inline def power(inline n: Long, x: Double) = ${powerCode('n, 'x)}
77

88
def powerCode(n: Expr[Long], x: Expr[Double]) (using Quotes): Expr[Double] =
9-
powerCode(n.valueOrError, x)
9+
powerCode(n.valueOrThrow, x)
1010

1111
def powerCode(n: Long, x: Expr[Double])(using Quotes): Expr[Double] =
1212
if (n == 0) '{1.0}

tests/pos-macros/quote-nested-object/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ object Macro {
99
inline def plus(inline n: Int, m: Int): Int = ${ plus('n, 'm) }
1010

1111
def plus(n: Expr[Int], m: Expr[Int]) (using Quotes): Expr[Int] =
12-
if (n.valueOrError == 0) m
12+
if (n.valueOrThrow == 0) m
1313
else '{ ${n} + $m }
1414

1515
object Implementation2 {
1616

1717
inline def plus(inline n: Int, m: Int): Int = ${ plus('n, 'm) }
1818

1919
def plus(n: Expr[Int], m: Expr[Int]) (using Quotes): Expr[Int] =
20-
if (n.valueOrError == 0) m
20+
if (n.valueOrThrow == 0) m
2121
else '{ ${n} + $m }
2222
}
2323
}

tests/pos-macros/quote-whitebox-2/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Macro {
66
transparent inline def charOrString(inline str: String): Any = ${ impl('str) }
77

88
def impl(strExpr: Expr[String]) (using Quotes)=
9-
val str = strExpr.valueOrError
9+
val str = strExpr.valueOrThrow
1010
if (str.length == 1) Expr(str.charAt(0)) else Expr(str)
1111

1212
}

tests/pos-staging/quote-0.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Macros {
1616
inline def power(inline n: Int, x: Double) = ${ powerCode('n, 'x) }
1717

1818
def powerCode(n: Expr[Int], x: Expr[Double]) (using Quotes): Expr[Double] =
19-
powerCode(n.valueOrError, x)
19+
powerCode(n.valueOrThrow, x)
2020

2121
def powerCode(n: Int, x: Expr[Double])(using Quotes): Expr[Double] =
2222
if (n == 0) '{1.0}

tests/run-macros/enum-nat-macro/Macros_2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ import Nat.*
2525
case 0 => acc
2626
case n => inner[Succ[N]](n - 1, '{Succ($acc)})
2727

28-
val i = int.valueOrError
28+
val i = int.valueOrThrow
2929
require(i >= 0)
3030
inner[Zero.type](i, '{Zero})

tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ object TypeToolbox {
4444
inline def fieldIn[T](inline mem: String): String = ${fieldInImpl[T]('mem)}
4545
private def fieldInImpl[T: Type](mem: Expr[String])(using Quotes) : Expr[String] = {
4646
import quotes.reflect.*
47-
val field = TypeTree.of[T].symbol.declaredField(mem.valueOrError)
47+
val field = TypeTree.of[T].symbol.declaredField(mem.valueOrThrow)
4848
Expr(if field.isNoSymbol then "" else field.name)
4949
}
5050

@@ -58,7 +58,7 @@ object TypeToolbox {
5858
inline def methodIn[T](inline mem: String): Seq[String] = ${methodInImpl[T]('mem)}
5959
private def methodInImpl[T: Type](mem: Expr[String])(using Quotes) : Expr[Seq[String]] = {
6060
import quotes.reflect.*
61-
Expr(TypeTree.of[T].symbol.declaredMethod(mem.valueOrError).map(_.name))
61+
Expr(TypeTree.of[T].symbol.declaredMethod(mem.valueOrThrow).map(_.name))
6262
}
6363

6464
inline def methodsIn[T]: Seq[String] = ${methodsInImpl[T]}
@@ -70,7 +70,7 @@ object TypeToolbox {
7070
inline def method[T](inline mem: String): Seq[String] = ${methodImpl[T]('mem)}
7171
private def methodImpl[T: Type](mem: Expr[String])(using Quotes) : Expr[Seq[String]] = {
7272
import quotes.reflect.*
73-
Expr(TypeTree.of[T].symbol.memberMethod(mem.valueOrError).map(_.name))
73+
Expr(TypeTree.of[T].symbol.memberMethod(mem.valueOrThrow).map(_.name))
7474
}
7575

7676
inline def methods[T]: Seq[String] = ${methodsImpl[T]}

tests/run-macros/i10914a/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ object Dsl {
2424
import quotes.reflect.*
2525
val inputs = c match
2626
case '{ Container($list) } =>
27-
list.valueOrError
27+
list.valueOrThrow
2828
case _ => report.throwError("Cannot Extract List from Container")
2929
'{ Entity(${Expr(inputs.head.value)}) }
3030
}

tests/run-macros/i10914b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object Dsl {
2828
import quotes.reflect.*
2929
val inputs = c match
3030
case '{ Container($list) } =>
31-
list.valueOrError
31+
list.valueOrThrow
3232
case _ => report.throwError("Cannot Extract List from Container")
3333
'{ Entity(${Expr(inputs.head.value)}) }
3434
}

tests/run-macros/i11856/Test_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ object Str:
55
${ evalConcat('a, 'b) }
66

77
def evalConcat(expra: Expr[String], exprb: Expr[String])(using Quotes): Expr[String] =
8-
val a = expra.valueOrError
9-
val b = exprb.valueOrError
8+
val a = expra.valueOrThrow
9+
val b = exprb.valueOrThrow
1010
Expr(a ++ b)
1111

1212
object I:
1313
inline def sum(inline a: Int, inline b: Int): Int =
1414
${ evalConcat('a, 'b) }
1515

1616
def evalConcat(expra: Expr[Int], exprb: Expr[Int])(using Quotes): Expr[Int] =
17-
val a = expra.valueOrError
18-
val b = exprb.valueOrError
17+
val a = expra.valueOrThrow
18+
val b = exprb.valueOrThrow
1919
Expr(a + b)

tests/run-macros/i4734/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ object Macros {
66
${ unrolledForeachImpl('seq, 'f, 'unrollSize) }
77

88
def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSizeExpr: Expr[Int]) (using Quotes): Expr[Unit] =
9-
unrolledForeachImpl(seq, f, unrollSizeExpr.valueOrError)
9+
unrolledForeachImpl(seq, f, unrollSizeExpr.valueOrThrow)
1010

1111
def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int)(using Quotes): Expr[Unit] = '{
1212
val size = ($seq).length

tests/run-macros/i4735/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ object Macro {
1414
while (i < size) {
1515
println("<log> start loop")
1616
${
17-
for (j <- new UnrolledRange(0, unrollSize.valueOrError)) '{
17+
for (j <- new UnrolledRange(0, unrollSize.valueOrThrow)) '{
1818
val element = ($seq)(i + ${Expr(j)})
1919
${Expr.betaReduce('{$f(element)})} // or `($f)(element)` if `f` should not be inlined
2020
}

tests/run-macros/i4803/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted.*
22

33
object PowerMacro {
44
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
5-
powerCode(x, n.valueOrError)
5+
powerCode(x, n.valueOrThrow)
66

77
def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
88
if (n == 0) '{1.0}

tests/run-macros/i4803b/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted.*
22

33
object PowerMacro {
44
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
5-
powerCode(x, n.valueOrError)
5+
powerCode(x, n.valueOrThrow)
66

77
def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
88
if (n == 0) '{1.0}

tests/run-macros/i4803c/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import scala.quoted.*
22

33
object PowerMacro {
44
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
5-
powerCode(x, n.valueOrError)
5+
powerCode(x, n.valueOrThrow)
66

77
def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
88
if (n == 0) '{1.0}

tests/run-macros/i5188a/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import scala.quoted.*
22

33
object Lib {
44
inline def sum(inline args: Int*): Int = ${ impl('args) }
5-
def impl(args: Expr[Seq[Int]]) (using Quotes): Expr[Int] = Expr(args.valueOrError.sum)
5+
def impl(args: Expr[Seq[Int]]) (using Quotes): Expr[Int] = Expr(args.valueOrThrow.sum)
66
}

0 commit comments

Comments
 (0)