diff options
author | Felix Mulder <felix.mulder@gmail.com> | 2016-10-03 10:02:00 +0200 |
---|---|---|
committer | Felix Mulder <felix.mulder@gmail.com> | 2016-10-10 13:25:36 +0200 |
commit | 41d642947c678efdd392bd01c632ecd53fd26b48 (patch) | |
tree | bfee887364340f4eff37911f2f2e29234b42d7e2 /src/dotty/tools/dotc/reporting | |
parent | f23ff3abba8663a0e7f64f79b556efd36cc86a83 (diff) | |
download | dotty-41d642947c678efdd392bd01c632ecd53fd26b48.tar.gz dotty-41d642947c678efdd392bd01c632ecd53fd26b48.tar.bz2 dotty-41d642947c678efdd392bd01c632ecd53fd26b48.zip |
Get rid of unnecessary fields in `MessageContainer`
Diffstat (limited to 'src/dotty/tools/dotc/reporting')
4 files changed, 26 insertions, 35 deletions
diff --git a/src/dotty/tools/dotc/reporting/Reporter.scala b/src/dotty/tools/dotc/reporting/Reporter.scala index b969fa878..b38334412 100644 --- a/src/dotty/tools/dotc/reporting/Reporter.scala +++ b/src/dotty/tools/dotc/reporting/Reporter.scala @@ -35,7 +35,7 @@ trait Reporting { this: Context => if (this.settings.verbose.value) this.echo(msg, pos) def echo(msg: => String, pos: SourcePosition = NoSourcePosition): Unit = - reporter.report(new Info(msg, pos, "Info")) + reporter.report(new Info(msg, pos)) def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit = reporter.report(msg.deprecationWarning(pos)) diff --git a/src/dotty/tools/dotc/reporting/diagnostic/Message.scala b/src/dotty/tools/dotc/reporting/diagnostic/Message.scala index f19191f4f..bdc899ea8 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/Message.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/Message.scala @@ -53,31 +53,31 @@ abstract class Message(val errorId: Int) { self => /** Enclose this message in an `Error` container */ def error(pos: SourcePosition) = - new Error(self, pos, explanation) + new Error(self, pos) /** Enclose this message in an `Warning` container */ def warning(pos: SourcePosition) = - new Warning(self, pos, explanation) + new Warning(self, pos) /** Enclose this message in an `Info` container */ def info(pos: SourcePosition) = - new Info(self, pos, explanation) + new Info(self, pos) /** Enclose this message in an `FeatureWarning` container */ def featureWarning(pos: SourcePosition) = - new FeatureWarning(self, pos, explanation) + new FeatureWarning(self, pos) /** Enclose this message in an `UncheckedWarning` container */ def uncheckedWarning(pos: SourcePosition) = - new UncheckedWarning(self, pos, explanation) + new UncheckedWarning(self, pos) /** Enclose this message in an `DeprecationWarning` container */ def deprecationWarning(pos: SourcePosition) = - new DeprecationWarning(self, pos, explanation) + new DeprecationWarning(self, pos) /** Enclose this message in an `MigrationWarning` container */ def migrationWarning(pos: SourcePosition) = - new MigrationWarning(self, pos, explanation) + new MigrationWarning(self, pos) } /** The fallback `Message` containing no explanation and having no `kind` */ diff --git a/src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala b/src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala index f49bebd94..7fd50bfdc 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala @@ -15,7 +15,7 @@ object MessageContainer { implicit class MessageContext(val c: Context) extends AnyVal { def shouldExplain(cont: MessageContainer): Boolean = { implicit val ctx: Context = c - cont.explanation match { + cont.contained.explanation match { case "" => false case _ => ctx.settings.explain.value } @@ -26,8 +26,7 @@ object MessageContainer { class MessageContainer( msgFn: => Message, val pos: SourcePosition, - val level: Int, - val explanation: String + val level: Int ) extends Exception with interfaces.Diagnostic { import MessageContainer._ private var myMsg: String = null diff --git a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala index 14978449a..e2b99af41 100644 --- a/src/dotty/tools/dotc/reporting/diagnostic/messages.scala +++ b/src/dotty/tools/dotc/reporting/diagnostic/messages.scala @@ -17,59 +17,51 @@ object messages { // `MessageContainer`s to be consumed by `Reporter` ---------------------- // class Error( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends MessageContainer(msgFn, pos, ERROR, explanation) + pos: SourcePosition + ) extends MessageContainer(msgFn, pos, ERROR) class Warning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends MessageContainer(msgFn, pos, WARNING, explanation) + pos: SourcePosition + ) extends MessageContainer(msgFn, pos, WARNING) class Info( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends MessageContainer(msgFn, pos, INFO, explanation) + pos: SourcePosition + ) extends MessageContainer(msgFn, pos, INFO) abstract class ConditionalWarning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends Warning(msgFn, pos, explanation) { + pos: SourcePosition + ) extends Warning(msgFn, pos) { def enablingOption(implicit ctx: Context): Setting[Boolean] } class FeatureWarning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends ConditionalWarning(msgFn, pos, explanation) { + pos: SourcePosition + ) extends ConditionalWarning(msgFn, pos) { def enablingOption(implicit ctx: Context) = ctx.settings.feature } class UncheckedWarning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends ConditionalWarning(msgFn, pos, explanation) { + pos: SourcePosition + ) extends ConditionalWarning(msgFn, pos) { def enablingOption(implicit ctx: Context) = ctx.settings.unchecked } class DeprecationWarning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends ConditionalWarning(msgFn, pos, explanation) { + pos: SourcePosition + ) extends ConditionalWarning(msgFn, pos) { def enablingOption(implicit ctx: Context) = ctx.settings.deprecation } class MigrationWarning( msgFn: => Message, - pos: SourcePosition, - explanation: String = "" - ) extends ConditionalWarning(msgFn, pos, explanation) { + pos: SourcePosition + ) extends ConditionalWarning(msgFn, pos) { def enablingOption(implicit ctx: Context) = ctx.settings.migration } |