aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2016-02-23 00:13:32 +0100
committerGuillaume Martres <smarter@ubuntu.com>2016-02-23 17:21:26 +0100
commit03486df4053ec75bce0ec4b6e5f16ceafcbf66e9 (patch)
treec8e93e6f96b0ae543a880c5c818ff980342423c7 /src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
parent9d24583b44e4b59d07d61c5f051c8e9a8a832148 (diff)
downloaddotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.tar.gz
dotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.tar.bz2
dotty-03486df4053ec75bce0ec4b6e5f16ceafcbf66e9.zip
ConsoleReporter: handling of non-sensical messages is now reusable
This is now handled by a separate trait HideNonSensicalMessages that can be mixed in, similar to UniqueMessagePositions. This way we'll be able to reuse this functionality for other kind of Reporters. This also means that we don't need `doReport` to return a Boolean anymore, so we change it to return a Unit as it did before 065a0026924f722e9844c8e314180bb4cebca236
Diffstat (limited to 'src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
new file mode 100644
index 000000000..a325fe9f7
--- /dev/null
+++ b/src/dotty/tools/dotc/reporting/HideNonSensicalMessages.scala
@@ -0,0 +1,20 @@
+package dotty.tools
+package dotc
+package reporting
+
+import core.Contexts.Context
+
+/**
+ * This trait implements `isHidden` so that we avoid reporting non-sensical messages.
+ */
+trait HideNonSensicalMessages extends Reporter {
+ /** Hides non-sensical messages, unless we haven't reported any error yet or
+ * `-Yshow-suppressed-errors` is set.
+ */
+ override def isHidden(d: Diagnostic)(implicit ctx: Context): Boolean =
+ super.isHidden(d) || {
+ d.isNonSensical &&
+ hasErrors && // if there are no errors yet, report even if diagnostic is non-sensical
+ !ctx.settings.YshowSuppressedErrors.value
+ }
+}