aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2016-10-07 13:47:27 +0200
committerFelix Mulder <felix.mulder@gmail.com>2016-10-10 13:25:37 +0200
commitb9e03b8d9246134afeacc925651139c079275479 (patch)
tree5a180af9a97fedff69db0b26dbeb70bcb99a84a8 /src/dotty/tools/dotc/reporting/ConsoleReporter.scala
parent45a2df1033c8cb13a3d80f429e31872e3d4174e1 (diff)
downloaddotty-b9e03b8d9246134afeacc925651139c079275479.tar.gz
dotty-b9e03b8d9246134afeacc925651139c079275479.tar.bz2
dotty-b9e03b8d9246134afeacc925651139c079275479.zip
Remove unnecessary printing of hints for `-explain`
Diffstat (limited to 'src/dotty/tools/dotc/reporting/ConsoleReporter.scala')
-rw-r--r--src/dotty/tools/dotc/reporting/ConsoleReporter.scala13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
index 82edd6a83..da3df6984 100644
--- a/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
+++ b/src/dotty/tools/dotc/reporting/ConsoleReporter.scala
@@ -94,7 +94,7 @@ class ConsoleReporter(
}).show else ""
/** Prints the message with the given position indication. */
- def printMessageAndPos(msg: Message, pos: SourcePosition, diagnosticLevel: String)(implicit ctx: Context): Unit = {
+ def printMessageAndPos(msg: Message, pos: SourcePosition, diagnosticLevel: String)(implicit ctx: Context): Boolean = {
printMessage(posStr(pos, diagnosticLevel, msg))
if (pos.exists) {
val (srcBefore, srcAfter, offset) = sourceLines(pos)
@@ -103,6 +103,7 @@ class ConsoleReporter(
printMessage((srcBefore ::: marker :: err :: srcAfter).mkString("\n"))
} else printMessage(msg.msg)
+ true
}
def printExplanation(m: Message)(implicit ctx: Context): Unit = {
@@ -114,11 +115,13 @@ class ConsoleReporter(
}
override def doReport(m: MessageContainer)(implicit ctx: Context): Unit = {
- m match {
+ val didPrint = m match {
case m: Error =>
- printMessageAndPos(m.contained, m.pos, "Error")
+ val didPrint = printMessageAndPos(m.contained, m.pos, "Error")
if (ctx.settings.prompt.value) displayPrompt()
+ didPrint
case m: ConditionalWarning if !m.enablingOption.value =>
+ false
case m: FeatureWarning =>
printMessageAndPos(m.contained, m.pos, "Feature Warning")
case m: DeprecationWarning =>
@@ -133,9 +136,9 @@ class ConsoleReporter(
printMessageAndPos(m.contained, m.pos, "Info")
}
- if (ctx.shouldExplain(m))
+ if (didPrint && ctx.shouldExplain(m))
printExplanation(m.contained)
- else if (m.contained.explanation.nonEmpty)
+ else if (didPrint && m.contained.explanation.nonEmpty)
printMessage("\nlonger explanation available when compiling with `-explain`")
}