Skip to content

Fix #10466: Update reporting API #10524

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

Merged
merged 2 commits into from
Nov 27, 2020
Merged
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 @@ -723,14 +723,14 @@ private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(using
case '{ $arg: t } =>
Expr.summon[Show[t]] match {
case Some(showExpr) => '{ $showExpr.show($arg) }
case None => Reporting.error(s"could not find implicit for ${showTp.show}", arg); '{???}
case None => report.error(s"could not find implicit for ${showTp.show}", arg); '{???}
}
}
val newArgsExpr = Varargs(argShowedExprs)
'{ $sc.s($newArgsExpr: _*) }
case _ =>
// `new StringContext(...).showMeExpr(args: _*)` not an explicit `showMeExpr"..."`
Reporting.error(s"Args must be explicit", argsExpr)
report.error(s"Args must be explicit", argsExpr)
'{???}
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/docs/reference/metaprogramming/tasty-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def natConstImpl(x: Expr[Int])(using Quotes): Expr[Int] = {
xTree match {
case Inlined(_, _, Literal(Constant(n: Int))) =>
if (n <= 0) {
Reporting.error("Parameter must be natural number")
report.error("Parameter must be natural number")
'{0}
} else {
xTree.asExprOf[Int]
}
case _ =>
Reporting.error("Parameter must be a known constant")
report.error("Parameter must be a known constant")
'{0}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object Macro {

def macroImplementation(using Quotes): Expr[Unit] = {
import quotes.reflect._
Reporting.error("some error", Position.ofMacroExpansion)
report.error("some error", Position.ofMacroExpansion)
'{ println("Implementation in MacroCompileError") }
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
$ copy-file changes/MacroCompileError.scala Macro.scala
> clean
> compile

$ copy-file changes/MacroRuntimeError.scala Macro.scala
> clean
> compile

$ copy-file changes/Main.scala Main.scala
$ copy-file changes/Macro.scala Macro.scala
> clean
> run

# use an implemntation of the macro that emits a compile time error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ object MacroRuntime {

def impl()(using q: Quotes): Expr[Unit] = {
import quotes.reflect._
Reporting.error("some error", Position.ofMacroExpansion)
report.error("some error", Position.ofMacroExpansion)
'{ println("Implementation in MacroCompileError") }
}

Expand Down