Skip to content

Rename Expr.valueOr{Error => Throw} #12022

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/reference/metaprogramming/macros.md
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ either a constant or is a parameter that will be a constant when instantiated. T
aspect is also important for macro expansion.

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

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

Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/quoted/Expr.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ object Expr {
* // value: T
* ```
*
* To directly get the value of an expression `expr: Expr[T]` consider using `expr.value`/`expr.valueOrError` instead.
* To directly get the value of an expression `expr: Expr[T]` consider using `expr.value`/`expr.valueOrThrow` instead.
* @syntax markdown
*/
def unapply[T](x: Expr[T])(using FromExpr[T])(using Quotes): Option[T] =
Expand Down
2 changes: 1 addition & 1 deletion library/src/scala/quoted/Exprs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Exprs:
* ...
* }
* ```
* To directly get the value of all expressions in a sequence `exprs: Seq[Expr[T]]` consider using `exprs.map(_.value)`/`exprs.map(_.valueOrError)` instead.
* To directly get the value of all expressions in a sequence `exprs: Seq[Expr[T]]` consider using `exprs.map(_.value)`/`exprs.map(_.valueOrThrow)` instead.
*/
def unapply[T](exprs: Seq[Expr[T]])(using FromExpr[T])(using Quotes): Option[Seq[T]] =
val builder = Seq.newBuilder[T]
Expand Down
11 changes: 10 additions & 1 deletion library/src/scala/quoted/Quotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,16 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
* Emits an error and throws if the expression does not represent a value or possibly contains side effects.
* Otherwise returns the value.
*/
def valueOrError(using FromExpr[T]): T =
@deprecated("Use valueOrThrow", "3.0.0")
def valueOrError(using e: FromExpr[T]): T =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def valueOrError(using e: FromExpr[T]): T =
def valueOrError(using FromExpr[T]): T =

valueOrThrow

/** Return the value of this expression.
*
* Emits an error and throws if the expression does not represent a value or possibly contains side effects.
* Otherwise returns the value.
*/
def valueOrThrow(using FromExpr[T]): T =
val fromExpr = summon[FromExpr[T]]
def reportError =
val msg = s"Expected a known value. \n\nThe value of: ${self.show}\ncould not be extracted using $fromExpr"
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/power-macro/PowerMacro.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ object PowerMacro {
inline def power(inline n: Long, x: Double) = ${ powerCode('n, 'x) }

def powerCode(n: Expr[Long], x: Expr[Double])(using Quotes): Expr[Double] =
powerCode(n.valueOrError, x)
powerCode(n.valueOrThrow, x)

def powerCode(n: Long, x: Expr[Double])(using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object E {

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

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

implicit def ev1[T: Type]: FromExpr[E[T]] = new FromExpr {
def unapply(x: Expr[E[T]])(using Quotes) = x match {
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/inline-option/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import scala.quoted.*

object Macro {
def impl(opt: Expr[Option[Int]]) (using Quotes): Expr[Int] = opt.valueOrError match {
def impl(opt: Expr[Option[Int]]) (using Quotes): Expr[Int] = opt.valueOrThrow match {
case Some(i) => Expr(i)
case None => '{-1}
}
Expand Down
44 changes: 22 additions & 22 deletions tests/neg-macros/inline-tuples-1/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
import scala.quoted.*

object Macros {
def tup1(tup: Expr[Tuple1[Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup2(tup: Expr[Tuple2[Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrError.productIterator.map(_.asInstanceOf[Int]).sum)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
def tup1(tup: Expr[Tuple1[Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup2(tup: Expr[Tuple2[Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrThrow.productIterator.map(_.asInstanceOf[Int]).sum)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
}
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-error-2/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import quoted.*
object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${ fooImpl('b) }
def fooImpl(b: Expr[Boolean])(using Quotes): Expr[Unit] =
'{println(${msg(b.valueOrError)})}
'{println(${msg(b.valueOrThrow)})}

def msg(b: Boolean)(using Quotes): Expr[String] =
if (b) '{"foo(true)"}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-error/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import quoted.*
object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
def fooImpl(b: Expr[Boolean])(using Quotes) : Expr[Unit] =
if (b.valueOrError) '{println("foo(true)")}
if (b.valueOrThrow) '{println("foo(true)")}
else { quotes.reflect.report.error("foo cannot be called with false"); '{ ??? } }
}
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-exception/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import quoted.*
object Macro_1 {
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
def fooImpl(b: Expr[Boolean]) (using Quotes): Expr[Unit] =
if (b.valueOrError) '{println("foo(true)")}
if (b.valueOrThrow) '{println("foo(true)")}
else ???
}
2 changes: 1 addition & 1 deletion tests/neg-macros/quote-whitebox/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted.*

object Macros {
transparent inline def defaultOf(inline str: String): Any = ${ defaultOfImpl('str) }
def defaultOfImpl(str: Expr[String]) (using Quotes): Expr[Any] = str.valueOrError match {
def defaultOfImpl(str: Expr[String]) (using Quotes): Expr[Any] = str.valueOrThrow match {
case "int" => '{1}
case "string" => '{"a"}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg-macros/reflect-inline/assert_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ object api {
${ stripImpl('x) }

private def stripImpl(x: Expr[String])(using Quotes): Expr[String] =
Expr(x.valueOrError.stripMargin)
Expr(x.valueOrThrow.stripMargin)

}
2 changes: 1 addition & 1 deletion tests/pos-macros/i11835/X.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ object X:
import quotes.reflect.*
println("="*120)
println(b.asTerm)
println(b.valueOrError)
println(b.valueOrThrow)
'{()}
2 changes: 1 addition & 1 deletion tests/pos-macros/power-macro/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object PowerMacro {
inline def power(inline n: Long, x: Double) = ${powerCode('n, 'x)}

def powerCode(n: Expr[Long], x: Expr[Double]) (using Quotes): Expr[Double] =
powerCode(n.valueOrError, x)
powerCode(n.valueOrThrow, x)

def powerCode(n: Long, x: Expr[Double])(using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
4 changes: 2 additions & 2 deletions tests/pos-macros/quote-nested-object/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ object Macro {
inline def plus(inline n: Int, m: Int): Int = ${ plus('n, 'm) }

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

object Implementation2 {

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

def plus(n: Expr[Int], m: Expr[Int]) (using Quotes): Expr[Int] =
if (n.valueOrError == 0) m
if (n.valueOrThrow == 0) m
else '{ ${n} + $m }
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/pos-macros/quote-whitebox-2/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Macro {
transparent inline def charOrString(inline str: String): Any = ${ impl('str) }

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

}
2 changes: 1 addition & 1 deletion tests/pos-staging/quote-0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object Macros {
inline def power(inline n: Int, x: Double) = ${ powerCode('n, 'x) }

def powerCode(n: Expr[Int], x: Expr[Double]) (using Quotes): Expr[Double] =
powerCode(n.valueOrError, x)
powerCode(n.valueOrThrow, x)

def powerCode(n: Int, x: Expr[Double])(using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/enum-nat-macro/Macros_2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ import Nat.*
case 0 => acc
case n => inner[Succ[N]](n - 1, '{Succ($acc)})

val i = int.valueOrError
val i = int.valueOrThrow
require(i >= 0)
inner[Zero.type](i, '{Zero})
6 changes: 3 additions & 3 deletions tests/run-macros/gestalt-type-toolbox-reflect/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object TypeToolbox {
inline def fieldIn[T](inline mem: String): String = ${fieldInImpl[T]('mem)}
private def fieldInImpl[T: Type](mem: Expr[String])(using Quotes) : Expr[String] = {
import quotes.reflect.*
val field = TypeTree.of[T].symbol.declaredField(mem.valueOrError)
val field = TypeTree.of[T].symbol.declaredField(mem.valueOrThrow)
Expr(if field.isNoSymbol then "" else field.name)
}

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

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

inline def methods[T]: Seq[String] = ${methodsImpl[T]}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i10914a/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ object Dsl {
import quotes.reflect.*
val inputs = c match
case '{ Container($list) } =>
list.valueOrError
list.valueOrThrow
case _ => report.throwError("Cannot Extract List from Container")
'{ Entity(${Expr(inputs.head.value)}) }
}
2 changes: 1 addition & 1 deletion tests/run-macros/i10914b/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object Dsl {
import quotes.reflect.*
val inputs = c match
case '{ Container($list) } =>
list.valueOrError
list.valueOrThrow
case _ => report.throwError("Cannot Extract List from Container")
'{ Entity(${Expr(inputs.head.value)}) }
}
8 changes: 4 additions & 4 deletions tests/run-macros/i11856/Test_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ object Str:
${ evalConcat('a, 'b) }

def evalConcat(expra: Expr[String], exprb: Expr[String])(using Quotes): Expr[String] =
val a = expra.valueOrError
val b = exprb.valueOrError
val a = expra.valueOrThrow
val b = exprb.valueOrThrow
Expr(a ++ b)

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

def evalConcat(expra: Expr[Int], exprb: Expr[Int])(using Quotes): Expr[Int] =
val a = expra.valueOrError
val b = exprb.valueOrError
val a = expra.valueOrThrow
val b = exprb.valueOrThrow
Expr(a + b)
2 changes: 1 addition & 1 deletion tests/run-macros/i4734/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Macros {
${ unrolledForeachImpl('seq, 'f, 'unrollSize) }

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

def unrolledForeachImpl(seq: Expr[IndexedSeq[Int]], f: Expr[Int => Unit], unrollSize: Int)(using Quotes): Expr[Unit] = '{
val size = ($seq).length
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i4735/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object Macro {
while (i < size) {
println("<log> start loop")
${
for (j <- new UnrolledRange(0, unrollSize.valueOrError)) '{
for (j <- new UnrolledRange(0, unrollSize.valueOrThrow)) '{
val element = ($seq)(i + ${Expr(j)})
${Expr.betaReduce('{$f(element)})} // or `($f)(element)` if `f` should not be inlined
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i4803/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted.*

object PowerMacro {
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
powerCode(x, n.valueOrError)
powerCode(x, n.valueOrThrow)

def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i4803b/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted.*

object PowerMacro {
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
powerCode(x, n.valueOrError)
powerCode(x, n.valueOrThrow)

def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i4803c/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import scala.quoted.*

object PowerMacro {
def powerCode(x: Expr[Double], n: Expr[Long]) (using Quotes): Expr[Double] =
powerCode(x, n.valueOrError)
powerCode(x, n.valueOrThrow)

def powerCode(x: Expr[Double], n: Long) (using Quotes): Expr[Double] =
if (n == 0) '{1.0}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-macros/i5188a/Macro_1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import scala.quoted.*

object Lib {
inline def sum(inline args: Int*): Int = ${ impl('args) }
def impl(args: Expr[Seq[Int]]) (using Quotes): Expr[Int] = Expr(args.valueOrError.sum)
def impl(args: Expr[Seq[Int]]) (using Quotes): Expr[Int] = Expr(args.valueOrThrow.sum)
}
Loading