Skip to content

Commit 7e33289

Browse files
Merge pull request #12056 from dotty-staging/use-abort-as-concept-for-stopping-macro-expansion
Add `Expr.valueOrAbort` and `reflect.report.errorAndAbort`
2 parents 75edcf8 + 43fec8f commit 7e33289

File tree

60 files changed

+189
-117
lines changed

Some content is hidden

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

60 files changed

+189
-117
lines changed

compiler/src/dotty/tools/dotc/transform/Splicer.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ object Splicer {
6363
catch {
6464
case ex: CompilationUnit.SuspendException =>
6565
throw ex
66-
case ex: scala.quoted.runtime.StopMacroExpansion if ctx.reporter.hasErrors =>
67-
// errors have been emitted
66+
case ex: scala.quoted.runtime.StopMacroExpansion =>
67+
if !ctx.reporter.hasErrors then
68+
report.error("Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users to facilitate debugging when aborting a macro expansion.", splicePos)
69+
// errors have been emitted
6870
EmptyTree
6971
case ex: StopInterpretation =>
7072
report.error(ex.msg, ex.pos)
@@ -546,4 +548,3 @@ object Splicer {
546548
}
547549
}
548550
}
549-

compiler/src/scala/quoted/runtime/impl/QuotesImpl.scala

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
4545
def matches(that: scala.quoted.Expr[Any]): Boolean =
4646
treeMatch(reflect.asTerm(self), reflect.asTerm(that)).nonEmpty
4747

48+
def valueOrAbort(using fromExpr: FromExpr[T]): T =
49+
def reportError =
50+
val tree = reflect.asTerm(self)
51+
val code = reflect.Printer.TreeCode.show(tree)
52+
val msg = s"Expected a known value. \n\nThe value of: $code\ncould not be extracted using $fromExpr"
53+
reflect.report.throwError(msg, self)
54+
fromExpr.unapply(self)(using QuotesImpl.this).getOrElse(reportError)
55+
4856
end extension
4957

5058
extension (self: scala.quoted.Expr[Any])
@@ -2750,14 +2758,23 @@ class QuotesImpl private (using val ctx: Context) extends Quotes, QuoteUnpickler
27502758
dotc.report.error(msg, pos)
27512759

27522760
def throwError(msg: String): Nothing =
2761+
errorAndAbort(msg)
2762+
2763+
def throwError(msg: String, expr: Expr[Any]): Nothing =
2764+
errorAndAbort(msg, expr)
2765+
2766+
def throwError(msg: String, pos: Position): Nothing =
2767+
errorAndAbort(msg, pos)
2768+
2769+
def errorAndAbort(msg: String): Nothing =
27532770
error(msg)
27542771
throw new scala.quoted.runtime.StopMacroExpansion
27552772

2756-
def throwError(msg: String, expr: Expr[Any]): Nothing =
2773+
def errorAndAbort(msg: String, expr: Expr[Any]): Nothing =
27572774
error(msg, expr)
27582775
throw new scala.quoted.runtime.StopMacroExpansion
27592776

2760-
def throwError(msg: String, pos: Position): Nothing =
2777+
def errorAndAbort(msg: String, pos: Position): Nothing =
27612778
error(msg, pos)
27622779
throw new scala.quoted.runtime.StopMacroExpansion
27632780

docs/docs/reference/metaprogramming/macros.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ aspect is also important for macro expansion.
460460

461461
To get values out of expressions containing constants `Expr` provides the method
462462
`value` (or `valueOrError`). This will convert the `Expr[T]` into a `Some[T]` (or `T`) when the
463-
expression contains value. Otherwise it will retrun `None` (or emit an error).
463+
expression contains value. Otherwise it will return `None` (or emit an error).
464464
To avoid having incidental val bindings generated by the inlining of the `def`
465465
it is recommended to use an inline parameter. To illustrate this, consider an
466466
implementation of the `power` function that makes use of a statically known exponent:

library/src/scala/quoted/Quotes.scala

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
5454
* Emits an error and throws if the expression does not represent a value or possibly contains side effects.
5555
* Otherwise returns the value.
5656
*/
57+
// TODO: deprecate in 3.1.0 and remove @experimental from valueOrAbort
58+
// @deprecated("Use valueOrThrow", "3.1.0")
5759
def valueOrError(using FromExpr[T]): T =
5860
val fromExpr = summon[FromExpr[T]]
5961
def reportError =
@@ -62,6 +64,14 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
6264
given Quotes = Quotes.this
6365
fromExpr.unapply(self).getOrElse(reportError)
6466

67+
/** Return the value of this expression.
68+
*
69+
* Emits an error and aborts if the expression does not represent a value or possibly contains side effects.
70+
* Otherwise returns the value.
71+
*/
72+
@experimental
73+
def valueOrAbort(using FromExpr[T]): T
74+
6575
end extension
6676

6777
// Extension methods for `Expr[Any]` that take another explicit type parameter
@@ -4169,12 +4179,30 @@ trait Quotes { self: runtime.QuoteUnpickler & runtime.QuoteMatching =>
41694179
def error(msg: String, pos: Position): Unit
41704180

41714181
/** Report an error at the position of the macro expansion and throw a StopMacroExpansion */
4182+
@experimental
4183+
def errorAndAbort(msg: String): Nothing
4184+
4185+
/** Report an error at the position of `expr` and throw a StopMacroExpansion */
4186+
@experimental
4187+
def errorAndAbort(msg: String, expr: Expr[Any]): Nothing
4188+
4189+
/** Report an error message at the given position and throw a StopMacroExpansion */
4190+
@experimental
4191+
def errorAndAbort(msg: String, pos: Position): Nothing
4192+
4193+
/** Report an error at the position of the macro expansion and throw a StopMacroExpansion */
4194+
// TODO: deprecate in 3.1.0 and remove @experimental from errorAndAbort
4195+
// @deprecated("Use errorAndAbort", "3.1.0")
41724196
def throwError(msg: String): Nothing
41734197

4174-
/** Report an error at the position of `expr` */
4198+
/** Report an error at the position of `expr` and throw a StopMacroExpansion */
4199+
// TODO: deprecate in 3.1.0 and remove @experimental from errorAndAbort
4200+
// @deprecated("Use errorAndAbort", "3.1.0")
41754201
def throwError(msg: String, expr: Expr[Any]): Nothing
41764202

41774203
/** Report an error message at the given position and throw a StopMacroExpansion */
4204+
// TODO: deprecate in 3.1.0 and remove @experimental from errorAndAbort
4205+
// @deprecated("Use errorAndAbort", "3.1.0")
41784206
def throwError(msg: String, pos: Position): Nothing
41794207

41804208
/** Report a warning at the position of the macro expansion */
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
package scala.quoted.runtime
22

3-
/** Throwable used to stop the expansion of a macro after an error was reported */
4-
class StopMacroExpansion extends Throwable
3+
/** Throwable used to abort the expansion of a macro after an error was reported */
4+
class StopMacroExpansion extends Throwable:
5+
6+
// Do not fill the stacktrace for performance.
7+
// We know that the stacktrace will be ignored
8+
// and only the reported error message will be used.
9+
override def fillInStackTrace(): Throwable = this

project/MiMaFilters.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,22 @@ import com.typesafe.tools.mima.core.ProblemFilters._
55
object MiMaFilters {
66
val Library: Seq[ProblemFilter] = Seq(
77
// New APIs marked @experimental in 3.0.1
8+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes.valueOrAbort"),
9+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),
810
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMember"),
911
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMembers"),
1012
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.methodMember"),
1113
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.methodMembers"),
1214
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.typeMember"),
1315
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.typeMembers"),
1416
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
17+
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#TermParamClauseMethods.isErased"),
18+
exclude[MissingClassProblem]("scala.annotation.experimental"),
1519
exclude[MissingClassProblem]("scala.annotation.experimental"),
1620
exclude[MissingClassProblem]("scala.annotation.internal.ErasedParam"),
21+
exclude[MissingClassProblem]("scala.annotation.internal.ErasedParam"),
22+
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes.valueOrAbort"),
23+
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#reportModule.errorAndAbort"),
1724
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMember"),
1825
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.fieldMembers"),
1926
exclude[ReversedMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SymbolMethods.methodMember"),

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.valueOrAbort, x)
99

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

tests/neg-macros/i9014/Macros_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import scala.quoted.*
22
trait Bar
33
inline given Bar = ${ impl }
4-
def impl(using Quotes): Expr[Bar] = quotes.reflect.report.throwError("Failed to expand!")
4+
def impl(using Quotes): Expr[Bar] = quotes.reflect.report.errorAndAbort("Failed to expand!")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import scala.quoted._
22
trait Bar
33
transparent inline given Bar = ${ impl }
4-
def impl(using Quotes): Expr[Bar] = quotes.reflect.report.throwError("Failed to expand!")
4+
def impl(using Quotes): Expr[Bar] = quotes.reflect.report.errorAndAbort("Failed to expand!")

tests/neg-macros/ill-abort.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
-- Error: tests/neg-macros/ill-abort/quoted_2.scala:1:15 ---------------------------------------------------------------
3+
1 |def test = fail() // error
4+
| ^^^^^^
5+
|Macro expansion was aborted by the macro without any errors reported. Macros should issue errors to end-users to facilitate debugging when aborting a macro expansion.
6+
| This location contains code that was inlined from quoted_1.scala:3
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted.*
2+
3+
inline def fail(): Unit = ${ impl }
4+
5+
private def impl(using Quotes) : Expr[Unit] =
6+
// should never be done without reporting error before (see docs)
7+
throw new scala.quoted.runtime.StopMacroExpansion
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def test = fail() // error

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.valueOrAbort.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.valueOrAbort 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.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
6+
def tup2(tup: Expr[Tuple2[Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
7+
def tup3(tup: Expr[Tuple3[Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
8+
def tup4(tup: Expr[Tuple4[Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
9+
def tup5(tup: Expr[Tuple5[Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
10+
def tup6(tup: Expr[Tuple6[Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.productIterator.map(_.asInstanceOf[Int]).sum)
11+
def tup7(tup: Expr[Tuple7[Int, Int, Int, Int, Int, Int, Int]]) (using Quotes): Expr[Int] = Expr(tup.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort.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.valueOrAbort)})}
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.valueOrAbort) '{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.valueOrAbort) '{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.valueOrAbort 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.valueOrAbort.stripMargin)
99

1010
}

0 commit comments

Comments
 (0)