diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-11-09 13:49:46 +0100 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-11-09 13:49:46 +0100 |
commit | 7332e9c1df756f6898e58231183517fefe93604d (patch) | |
tree | fdd1078db6fb2fe42e379cf3532e2a6d7e7340c1 /src/dotty/tools/dotc/reporting | |
parent | e0839e97cac2d212aae8eebbf3f828f91a27ddab (diff) | |
download | dotty-7332e9c1df756f6898e58231183517fefe93604d.tar.gz dotty-7332e9c1df756f6898e58231183517fefe93604d.tar.bz2 dotty-7332e9c1df756f6898e58231183517fefe93604d.zip |
Change `ClassicReporter` to `TestReporter` in test sources
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
-rw-r--r-- | src/dotty/tools/dotc/reporting/ClassicReporter.scala | 85 | ||||
-rw-r--r-- | src/dotty/tools/dotc/reporting/diagnostic/messages.scala | 19 |
2 files changed, 19 insertions, 85 deletions
diff --git a/src/dotty/tools/dotc/reporting/ClassicReporter.scala b/src/dotty/tools/dotc/reporting/ClassicReporter.scala deleted file mode 100644 index bd881eb4f..000000000 --- a/src/dotty/tools/dotc/reporting/ClassicReporter.scala +++ /dev/null @@ -1,85 +0,0 @@ -package dotty.tools -package dotc -package reporting - -import scala.collection.mutable -import util.SourcePosition -import core.Contexts._ -import Reporter._ -import java.io.{ BufferedReader, IOException, PrintWriter } -import scala.reflect.internal.util._ -import diagnostic.{ Message, MessageContainer, NoExplanation } -import diagnostic.messages._ - -/** - * This class implements a Reporter that displays messages on a text - * console. - */ -class ClassicReporter( - reader: BufferedReader = Console.in, - writer: PrintWriter = new PrintWriter(Console.err, true)) - extends Reporter with UniqueMessagePositions with HideNonSensicalMessages { - - import MessageContainer._ - - /** maximal number of error messages to be printed */ - protected def ErrorLimit = 100 - - def printPos(pos: SourcePosition): Unit = - if (pos.exists) { - printMessage(pos.lineContent.stripLineEnd) - printMessage(" " * pos.column + "^") - if (pos.outer.exists) { - printMessage(s"\n... this location is in code that was inlined at ${pos.outer}:\n") - printPos(pos.outer) - } - } - - /** Prints the message. */ - def printMessage(msg: String): Unit = { writer.print(msg + "\n"); writer.flush() } - - /** Prints the message with the given position indication. */ - def printMessageAndPos(msg: String, pos: SourcePosition)(implicit ctx: Context): Unit = { - val posStr = if (pos.exists) s"$pos: " else "" - printMessage(posStr + msg) - printPos(pos) - } - - override def doReport(m: MessageContainer)(implicit ctx: Context): Unit = m match { - case m: Error => - printMessageAndPos(s"error: ${m.contained}", m.pos) - if (ctx.settings.prompt.value) displayPrompt() - case m: ConditionalWarning if !m.enablingOption.value => - case m: FeatureWarning => - printMessageAndPos(s"feature warning: ${m.contained.msg}", m.pos) - case m: DeprecationWarning => - printMessageAndPos(s"deprecation warning: ${m.contained.msg}", m.pos) - case m: UncheckedWarning => - printMessageAndPos(s"unchecked warning: ${m.contained.msg}", m.pos) - case m: Info => - printMessageAndPos(m.contained.msg, m.pos) - case m: MigrationWarning => - printMessageAndPos(s"migration warning: ${m.contained.msg}", m.pos) - case m: Warning => - printMessageAndPos(s"warning: ${m.contained.msg}", m.pos) - case _ => - printMessageAndPos(m.contained.msg, m.pos) - } - - def displayPrompt(): Unit = { - writer.print("\na)bort, s)tack, r)esume: ") - writer.flush() - if (reader != null) { - val response = reader.read().asInstanceOf[Char].toLower - if (response == 'a' || response == 's') { - Thread.dumpStack() - if (response == 'a') - sys.exit(1) - } - writer.print("\n") - writer.flush() - } - } - - override def flush()(implicit ctx: Context): Unit = { writer.flush() } -} diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 65fafd092..649f2a8f8 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -768,4 +768,23 @@ object messages { | - null |""" } + + case class PatternMatchExhaustivity(uncovered: String)(implicit ctx: Context) + extends Message(29) { + val kind = "Pattern Match Exhaustivity" + val msg = + hl"""|match may not be exhaustive. + | + |It would fail on: $uncovered""" + + + val explanation = "" + } + + case class MatchCaseUnreachable()(implicit ctx: Context) + extends Message(30) { + val kind = s"""Match ${hl"case"} Unreachable""" + val msg = "unreachable code" + val explanation = "" + } } |