Skip to content

Commit 86cc7f8

Browse files
Merge pull request #9380 from dotty-staging/rename-Reporing-to-report
Rename `scala.quoted.Reporting` to `report`
2 parents 03aa171 + 1bfc467 commit 86cc7f8

File tree

25 files changed

+44
-44
lines changed

25 files changed

+44
-44
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ object Splicer {
5454
catch {
5555
case ex: CompilationUnit.SuspendException =>
5656
throw ex
57-
case ex: scala.quoted.Reporting.StopQuotedContext if ctx.reporter.hasErrors =>
57+
case ex: scala.quoted.report.StopQuotedContext if ctx.reporter.hasErrors =>
5858
// errors have been emitted
5959
EmptyTree
6060
case ex: StopInterpretation =>
@@ -391,7 +391,7 @@ object Splicer {
391391
throw new StopInterpretation(sw.toString, pos)
392392
case ex: InvocationTargetException =>
393393
ex.getTargetException match {
394-
case ex: scala.quoted.Reporting.StopQuotedContext =>
394+
case ex: scala.quoted.report.StopQuotedContext =>
395395
throw ex
396396
case MissingClassDefinedInCurrentRun(sym) if ctx.compilationUnit.isSuspendable =>
397397
if (ctx.settings.XprintSuspension.value)

library/src-bootstrapped/dotty/internal/CompileTimeMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ object CompileTimeMacros:
88
case (Expr.StringContext(Consts(parts)), Varargs(args2)) =>
99
Expr(StringContext(parts: _*).s(args2.map(_.show): _*))
1010
case _ =>
11-
Reporting.throwError("compiletime.code must be used as a string interpolator `code\"...\"`")
11+
report.throwError("compiletime.code must be used as a string interpolator `code\"...\"`")

library/src-bootstrapped/dotty/internal/StringContextMacro.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ object StringContextMacro {
6363

6464
val (partsExpr, parts) = strCtxExpr match {
6565
case Expr.StringContext(p1 @ Consts(p2)) => (p1.toList, p2.toList)
66-
case _ => Reporting.throwError("Expected statically known String Context", strCtxExpr)
66+
case _ => report.throwError("Expected statically known String Context", strCtxExpr)
6767
}
6868

6969
val args = argsExpr match {
7070
case Varargs(args) => args
71-
case _ => Reporting.throwError("Expected statically known argument list", argsExpr)
71+
case _ => report.throwError("Expected statically known argument list", argsExpr)
7272
}
7373

7474
val reporter = new Reporter{

library/src-bootstrapped/scala/quoted/Expr.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract class Expr[+T] private[scala] {
2727
* Otherwise returns the value.
2828
*/
2929
final def unliftOrError[U >: T](using qctx: QuoteContext, unlift: Unliftable[U]): U =
30-
unlift(this).getOrElse(Reporting.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be unlifted using $unlift", this))
30+
unlift(this).getOrElse(report.throwError(s"Expected a known value. \n\nThe value of: $show\ncould not be unlifted using $unlift", this))
3131

3232
/** Pattern matches `this` against `that`. Effectively performing a deep equality check.
3333
* It does the equivalent of

library/src-bootstrapped/scala/quoted/Reporting.scala renamed to library/src-bootstrapped/scala/quoted/report.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package scala.quoted
22

3-
object Reporting {
3+
object report:
44

55
/** Report an error at the position of the macro expansion */
66
def error(msg: => String)(using qctx: QuoteContext): Unit =
@@ -32,4 +32,7 @@ object Reporting {
3232
/** Throwable used to stop the expansion of a macro after an error was reported */
3333
class StopQuotedContext extends Throwable
3434

35-
}
35+
end report
36+
37+
@deprecated("Use scala.quoted.report", "")
38+
def Reporting: report.type = report
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package scala.quoted
22

3-
object Reporting {
4-
3+
object report:
54
/** Throwable used to stop the expansion of a macro after an error was reported */
65
class StopQuotedContext extends Throwable
7-
8-
}

tests/neg-macros/BigFloat/BigFloatFromDigitsImpl_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object BigFloatFromDigitsImpl:
1010
val BigFloat(m, e) = BigFloat(ds)
1111
'{BigFloat(${Expr(m)}, ${Expr(e)})}
1212
catch case ex: FromDigits.FromDigitsException =>
13-
Reporting.error(ex.getMessage)
13+
report.error(ex.getMessage)
1414
'{BigFloat(0, 0)}
1515
case digits =>
1616
'{BigFloat($digits)}

tests/neg-macros/GenericNumLits/EvenFromDigitsImpl_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object EvenFromDigitsImpl:
99
try evenFromDigits(ds)
1010
catch {
1111
case ex: FromDigits.FromDigitsException =>
12-
Reporting.error(ex.getMessage)
12+
report.error(ex.getMessage)
1313
Even(0)
1414
}
1515
'{Even(${Expr(ev.n)})}

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 as Bar = ${ impl }
4-
def impl(using qctx: QuoteContext): Expr[Bar] = Reporting.throwError("Failed to expand!")
4+
def impl(using qctx: QuoteContext): Expr[Bar] = report.throwError("Failed to expand!")

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

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

88
def msg(b: Boolean)(using qctx: QuoteContext): Expr[String] =
99
if (b) '{"foo(true)"}
10-
else { Reporting.error("foo cannot be called with false"); '{ ??? } }
10+
else { report.error("foo cannot be called with false"); '{ ??? } }
1111

1212
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ object Macro_1 {
44
inline def foo(inline b: Boolean): Unit = ${fooImpl('b)}
55
def fooImpl(b: Expr[Boolean])(using qctx: QuoteContext) : Expr[Unit] =
66
if (b.unliftOrError) '{println("foo(true)")}
7-
else { Reporting.error("foo cannot be called with false"); '{ ??? } }
7+
else { report.error("foo cannot be called with false"); '{ ??? } }
88
}

tests/neg-staging/i5941/macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Lens {
3333
apply($getter)(setter)
3434
}
3535
case _ =>
36-
Reporting.error("Unsupported syntax. Example: `GenLens[Address](_.streetNumber)`")
36+
report.error("Unsupported syntax. Example: `GenLens[Address](_.streetNumber)`")
3737
'{???}
3838
}
3939
}

tests/neg-with-compiler/GenericNumLits/EvenFromDigitsImpl_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ object EvenFromDigitsImpl:
99
try evenFromDigits(ds)
1010
catch {
1111
case ex: FromDigits.FromDigitsException =>
12-
Reporting.error(ex.getMessage)
12+
report.error(ex.getMessage)
1313
Even(0)
1414
}
1515
'{Even(${Expr(ev.n)})}

tests/run-macros/BigFloat/BigFloatFromDigitsImpl_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object BigFloatFromDigitsImpl:
1010
val BigFloat(m, e) = BigFloat(ds)
1111
'{BigFloat(${Expr(m)}, ${Expr(e)})}
1212
catch case ex: FromDigits.FromDigitsException =>
13-
Reporting.error(ex.getMessage)
13+
report.error(ex.getMessage)
1414
'{BigFloat(0, 0)}
1515
case digits =>
1616
'{BigFloat($digits)}

tests/run-macros/f-interpolation-1/FQuote_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object FQuote {
3838
values.forall(isStringConstant) =>
3939
values.collect { case Literal(Constant(value: String)) => value }
4040
case tree =>
41-
Reporting.error(s"String literal expected, but ${tree.showExtractors} found")
41+
report.error(s"String literal expected, but ${tree.showExtractors} found")
4242
return '{???}
4343
}
4444

tests/run-macros/i5941/macro_1.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object Lens {
5353
apply($getter)(setter)
5454
}
5555
case _ =>
56-
Reporting.error("Unsupported syntax. Example: `GenLens[Address](_.streetNumber)`")
56+
report.error("Unsupported syntax. Example: `GenLens[Address](_.streetNumber)`")
5757
'{???}
5858
}
5959
}
@@ -95,7 +95,7 @@ object Iso {
9595
// 2. A must be a tuple
9696
// 3. The parameters of S must match A
9797
if (tpS.classSymbol.flatMap(cls => if (cls.flags.is(Flags.Case)) Some(true) else None).isEmpty) {
98-
Reporting.error("Only support generation for case classes")
98+
report.error("Only support generation for case classes")
9999
return '{???}
100100
}
101101

@@ -106,13 +106,13 @@ object Iso {
106106
}
107107

108108
if (cls.caseFields.size != 1) {
109-
Reporting.error("Use GenIso.fields for case classes more than one parameter")
109+
report.error("Use GenIso.fields for case classes more than one parameter")
110110
return '{???}
111111
}
112112

113113
val fieldTp = tpS.memberType(cls.caseFields.head)
114114
if (!(fieldTp =:= tpA)) {
115-
Reporting.error(s"The type of case class field $fieldTp does not match $tpA")
115+
report.error(s"The type of case class field $fieldTp does not match $tpA")
116116
'{???}
117117
} else '{
118118
// (p: S) => p._1
@@ -139,7 +139,7 @@ object Iso {
139139
val cls = tpS.classSymbol.get
140140

141141
if (cls.caseFields.size != 0) {
142-
Reporting.error("Use GenIso.fields for case classes more than one parameter")
142+
report.error("Use GenIso.fields for case classes more than one parameter")
143143
return '{???}
144144
}
145145

@@ -154,7 +154,7 @@ object Iso {
154154
}
155155
}
156156
else {
157-
Reporting.error("Only support generation for case classes or singleton types")
157+
report.error("Only support generation for case classes or singleton types")
158158
'{???}
159159
}
160160
}

tests/run-macros/i8671/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ object FileName {
1818
case Right(fn) =>
1919
'{FileName.unsafe(${Expr(fn.name)})} // Or `Expr(fn)` if there is a `Liftable[FileName]`
2020
case Left(_) =>
21-
Reporting.throwError(s"$s is not a valid file name! It must not contain a /", fileName)
21+
report.throwError(s"$s is not a valid file name! It must not contain a /", fileName)
2222
}
2323

2424
case _ =>
25-
Reporting.throwError(s"$fileName is not a valid file name. It must be a literal string", fileName)
25+
report.throwError(s"$fileName is not a valid file name. It must be a literal string", fileName)
2626
}
2727
}
2828

tests/run-macros/quote-matcher-symantics-3/quoted_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ object Macros {
6666
case FromEnv(expr) => expr.asInstanceOf[Expr[R[T]]]
6767

6868
case _ =>
69-
Reporting.error("Expected explicit value but got: " + e.show, e)
69+
report.error("Expected explicit value but got: " + e.show, e)
7070
'{ ??? }
7171

7272
})

tests/run-macros/refined-selectable-macro/Macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ object Macro {
2626
case _: TypeBounds =>
2727
rec(parent)
2828
case _: MethodType | _: PolyType | _: TypeBounds | _: ByNameType =>
29-
Reporting.warning(s"Ignored `$name` as a field of the record", s)
29+
report.warning(s"Ignored `$name` as a field of the record", s)
3030
rec(parent)
3131
case info: Type =>
3232
(name, info) :: rec(parent)
@@ -60,10 +60,10 @@ object Macro {
6060
// Tuple2(S, T) where S must be a constant string type
6161
case AppliedType(parent, ConstantType(Constant(name: String)) :: (info: Type) :: Nil) if (parent.typeSymbol == defn.TupleClass(2)) =>
6262
if seen(name) then
63-
Reporting.error(s"Repeated record name: $name", s)
63+
report.error(s"Repeated record name: $name", s)
6464
(seen + name, (name, info))
6565
case _ =>
66-
Reporting.error("Tuple type was not explicit expected `(S, T)` where S is a singleton string", s)
66+
report.error("Tuple type was not explicit expected `(S, T)` where S is a singleton string", s)
6767
(seen, ("<error>", defn.AnyType))
6868
}
6969
}
@@ -82,7 +82,7 @@ object Macro {
8282
})._2
8383
// Tuple
8484
case _ =>
85-
Reporting.error("Tuple type must be of known size", s)
85+
report.error("Tuple type must be of known size", s)
8686
Nil
8787
}
8888
}

tests/run-macros/string-context-implicits/Macro_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using
1111
val showTp = '[Show[$tp]]
1212
Expr.summon(using showTp) match {
1313
case Some(showExpr) => '{ $showExpr.show($arg) }
14-
case None => Reporting.error(s"could not find implicit for ${showTp.show}", arg); '{???}
14+
case None => report.error(s"could not find implicit for ${showTp.show}", arg); '{???}
1515
}
1616
}
1717
val newArgsExpr = Varargs(argShowedExprs)
1818
'{ $sc.s($newArgsExpr: _*) }
1919
case _ =>
2020
// `new StringContext(...).showMeExpr(args: _*)` not an explicit `showMeExpr"..."`
21-
Reporting.error(s"Args must be explicit", argsExpr)
21+
report.error(s"Args must be explicit", argsExpr)
2222
'{???}
2323
}
2424
}

tests/run-macros/tasty-interpolation-1/Macro.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import scala.quoted._
33
import scala.language.implicitConversions
4-
import scala.quoted.Reporting.error
4+
import scala.quoted.report.error
55

66
object Macro {
77

tests/run-macros/tasty-macro-const/quoted_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ object Macros {
1010
xTree match {
1111
case Inlined(_, _, Literal(Constant(n: Int))) =>
1212
if (n <= 0) {
13-
Reporting.error("Parameter must be natural number")
13+
report.error("Parameter must be natural number")
1414
'{0}
1515
} else {
1616
xTree.seal.cast[Int]
1717
}
1818
case _ =>
19-
Reporting.error("Parameter must be a known constant")
19+
report.error("Parameter must be a known constant")
2020
'{0}
2121
}
2222
}

tests/run-macros/xml-interpolation-1/XmlQuote_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ object XmlQuote {
4848
values.forall(isStringConstant) =>
4949
values.collect { case Literal(Constant(value: String)) => value }
5050
case tree =>
51-
Reporting.error(s"String literal expected, but ${tree.showExtractors} found")
51+
report.error(s"String literal expected, but ${tree.showExtractors} found")
5252
return '{ ??? }
5353
}
5454

tests/run-macros/xml-interpolation-2/XmlQuote_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ object XmlQuote {
4343
values.iterator.map {
4444
case Literal(Constant(value: String)) => value
4545
case _ =>
46-
Reporting.error("Expected statically known String")
46+
report.error("Expected statically known String")
4747
return '{???}
4848
}.toList
4949
case _ =>
50-
Reporting.error("Expected statically known StringContext")
50+
report.error("Expected statically known StringContext")
5151
return '{???}
5252
}
5353
case _ =>
54-
Reporting.error("Expected statically known SCOps")
54+
report.error("Expected statically known SCOps")
5555
return '{???}
5656
}
5757

tests/run-staging/staged-tuples/StagedTuple.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ object StagedTuple {
132132
else {
133133
def fallbackApply(): Expr[Elem[Tup, N]] = nValue match {
134134
case Some(n) =>
135-
Reporting.error("index out of bounds: " + n, tup)
135+
report.error("index out of bounds: " + n, tup)
136136
'{ throw new IndexOutOfBoundsException(${Expr(n.toString)}) }
137137
case None => '{scala.runtime.Tuple.apply($tup, $n)}.as[Elem[Tup, N]]
138138
}

0 commit comments

Comments
 (0)