diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-07 13:47:27 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:37 +0200 |
commit | b9e03b8d9246134afeacc925651139c079275479 (patch) | |
tree | 5a180af9a97fedff69db0b26dbeb70bcb99a84a8 /src/dotty/tools/dotc | |
parent | 45a2df1033c8cb13a3d80f429e31872e3d4174e1 (diff) | |
download | dotty-b9e03b8d9246134afeacc925651139c079275479.tar.gz dotty-b9e03b8d9246134afeacc925651139c079275479.tar.bz2 dotty-b9e03b8d9246134afeacc925651139c079275479.zip |
Remove unnecessary printing of hints for `-explain`
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r-- | src/dotty/tools/dotc/printing/Formatting.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/ConsoleReporter.scala | 13 |
2 files changed, 9 insertions, 6 deletions
diff --git a/src/dotty/tools/dotc/printing/Formatting.scala b/src/dotty/tools/dotc/printing/Formatting.scala index 719c23e84..e7968b14a 100644 --- a/src/dotty/tools/dotc/printing/Formatting.scala +++ b/src/dotty/tools/dotc/printing/Formatting.scala @@ -90,7 +90,7 @@ object Formatting { } } - private def wrapNonSensical(arg: Any, str: String)(implicit ctx: Context): String = { + private def wrapNonSensical(arg: Any /* Type | Symbol */, str: String)(implicit ctx: Context): String = { import MessageContainer._ def isSensical(arg: Any): Boolean = arg match { case tpe: Type => 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`") } |