Skip to content

Commit 396d39f

Browse files
committed
Adapt to new reporting outside of compiler
1 parent 653fe1a commit 396d39f

File tree

6 files changed

+9
-16
lines changed

6 files changed

+9
-16
lines changed

bench/src/main/scala/Benchmarks.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Worker extends Driver {
102102
}
103103
catch {
104104
case ex: FatalError =>
105-
ctx.error(ex.getMessage) // signals that we should fail compilation.
105+
report.error(ex.getMessage) // signals that we should fail compilation.
106106
ctx.reporter
107107
}
108108
else ctx.reporter

compiler/src/dotty/tools/dotc/core/Phases.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@ import Periods._
1616
import typer.{FrontEnd, RefChecks}
1717
import ast.tpd
1818

19-
trait Phases {
20-
self: Context =>
21-
22-
import Phases._
23-
}
24-
2519
object Phases {
2620

2721
inline def phaseOf(id: PhaseId)(using Context): Phase =

docs/docs/reference/changed-features/compiler-plugins.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class DivideZeroPhase extends PluginPhase {
8181
tree match {
8282
case Apply(Select(rcvr, nme.DIV), List(Literal(Constant(0))))
8383
if rcvr.tpe <:< defn.IntType =>
84-
ctx.error("dividing by zero", tree.pos)
84+
report.error("dividing by zero", tree.pos)
8585
case _ =>
8686
()
8787
}
@@ -90,7 +90,7 @@ class DivideZeroPhase extends PluginPhase {
9090
}
9191
```
9292

93-
The plugin main class (`DivideZero`) must extend the trait `StandardPlugin`
93+
The plugin main class (`DivideZero`) must extend the trait `StandardPlugin`
9494
and implement the method `init` that takes the plugin's options as argument
9595
and returns a list of `PluginPhase`s to be inserted into the compilation pipeline.
9696

docs/docs/reference/changed-features/numeric-literals.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,7 @@ strings `fromDigitsImpl(digits)` is simply `apply(digits)`, i.e. everything is
226226
evaluated at runtime in this case.
227227

228228
The interesting part is the `catch` part of the case where `digits` is constant.
229-
If the `apply` method throws a `FromDigitsException`, the exception's message is issued as a compile time error
230-
in the `ctx.error(ex.getMessage)` call.
229+
If the `apply` method throws a `FromDigitsException`, the exception's message is issued as a compile time error in the `ctx.error(ex.getMessage)` call.
231230

232231
With this new implementation, a definition like
233232
```scala

sbt-dotty/sbt-test/sbt-dotty/analyzer-plugin/plugin/Analyzer.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InitChecker extends PluginPhase {
3434

3535
private def checkDef(tree: Tree)(implicit ctx: Context): Tree = {
3636
if (tree.symbol.defTree.isEmpty)
37-
ctx.error("cannot get tree for " + tree.show, tree.sourcePos)
37+
report.error("cannot get tree for " + tree.show, tree.sourcePos)
3838
tree
3939
}
4040

@@ -51,17 +51,17 @@ class InitChecker extends PluginPhase {
5151

5252
if (enclosingPkg == helloPkgSym) { // source code
5353
checkDef(tree)
54-
ctx.warning("tree: " + tree.symbol.defTree.show)
54+
report.warning("tree: " + tree.symbol.defTree.show)
5555
}
5656
else if (enclosingPkg == libPkgSym) { // tasty from library
5757
checkDef(tree)
5858
// check that all sub-definitions have trees set properly
5959
// make sure that are no cycles in the code
6060
transformAllDeep(tree.symbol.defTree)
61-
ctx.warning("tree: " + tree.symbol.defTree.show)
61+
report.warning("tree: " + tree.symbol.defTree.show)
6262
}
6363
else {
64-
ctx.warning(s"${tree.symbol} is neither in lib nor hello, owner = $enclosingPkg", tree.sourcePos)
64+
report.warning(s"${tree.symbol} is neither in lib nor hello, owner = $enclosingPkg", tree.sourcePos)
6565
}
6666
tree
6767
}

sbt-dotty/sbt-test/sbt-dotty/compiler-plugin/plugin/DivideZero.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class DivideZero extends PluginPhase with StandardPlugin {
3333

3434
override def transformApply(tree: tpd.Apply)(implicit ctx: Context): tpd.Tree = tree match {
3535
case tpd.Apply(fun, tpd.Literal(Constants.Constant(v)) :: Nil) if isNumericDivide(fun.symbol) && v == 0 =>
36-
ctx.error("divide by zero", tree.sourcePos)
36+
report.error("divide by zero", tree.sourcePos)
3737
tpd.Literal(Constant(0))
3838
case _ =>
3939
tree

0 commit comments

Comments
 (0)