Skip to content

Commit 41d6429

Browse files
committed
Get rid of unnecessary fields in MessageContainer
1 parent f23ff3a commit 41d6429

File tree

6 files changed

+26
-40
lines changed

6 files changed

+26
-40
lines changed

interfaces/src/main/java/dotty/tools/dotc/interfaces/Diagnostic.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ public interface Diagnostic {
1717
/** @return The message to report */
1818
String message();
1919

20-
/** @return The explanation behind the message */
21-
String explanation();
22-
2320
/** @return Level of the diagnostic, can be either ERROR, WARNING or INFO */
2421
int level();
2522

src/dotty/tools/dotc/ast/Trees.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,6 @@ object Trees {
308308
if (rawMods.is(Synthetic)) Position(pos.point, pos.point)
309309
else Position(pos.point, pos.point + name.length, pos.point)
310310
else pos
311-
312-
313311
}
314312

315313
/** A ValDef or DefDef tree */

src/dotty/tools/dotc/reporting/Reporter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait Reporting { this: Context =>
3535
if (this.settings.verbose.value) this.echo(msg, pos)
3636

3737
def echo(msg: => String, pos: SourcePosition = NoSourcePosition): Unit =
38-
reporter.report(new Info(msg, pos, "Info"))
38+
reporter.report(new Info(msg, pos))
3939

4040
def deprecationWarning(msg: => Message, pos: SourcePosition = NoSourcePosition): Unit =
4141
reporter.report(msg.deprecationWarning(pos))

src/dotty/tools/dotc/reporting/diagnostic/Message.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,31 @@ abstract class Message(val errorId: Int) { self =>
5353

5454
/** Enclose this message in an `Error` container */
5555
def error(pos: SourcePosition) =
56-
new Error(self, pos, explanation)
56+
new Error(self, pos)
5757

5858
/** Enclose this message in an `Warning` container */
5959
def warning(pos: SourcePosition) =
60-
new Warning(self, pos, explanation)
60+
new Warning(self, pos)
6161

6262
/** Enclose this message in an `Info` container */
6363
def info(pos: SourcePosition) =
64-
new Info(self, pos, explanation)
64+
new Info(self, pos)
6565

6666
/** Enclose this message in an `FeatureWarning` container */
6767
def featureWarning(pos: SourcePosition) =
68-
new FeatureWarning(self, pos, explanation)
68+
new FeatureWarning(self, pos)
6969

7070
/** Enclose this message in an `UncheckedWarning` container */
7171
def uncheckedWarning(pos: SourcePosition) =
72-
new UncheckedWarning(self, pos, explanation)
72+
new UncheckedWarning(self, pos)
7373

7474
/** Enclose this message in an `DeprecationWarning` container */
7575
def deprecationWarning(pos: SourcePosition) =
76-
new DeprecationWarning(self, pos, explanation)
76+
new DeprecationWarning(self, pos)
7777

7878
/** Enclose this message in an `MigrationWarning` container */
7979
def migrationWarning(pos: SourcePosition) =
80-
new MigrationWarning(self, pos, explanation)
80+
new MigrationWarning(self, pos)
8181
}
8282

8383
/** The fallback `Message` containing no explanation and having no `kind` */

src/dotty/tools/dotc/reporting/diagnostic/MessageContainer.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object MessageContainer {
1515
implicit class MessageContext(val c: Context) extends AnyVal {
1616
def shouldExplain(cont: MessageContainer): Boolean = {
1717
implicit val ctx: Context = c
18-
cont.explanation match {
18+
cont.contained.explanation match {
1919
case "" => false
2020
case _ => ctx.settings.explain.value
2121
}
@@ -26,8 +26,7 @@ object MessageContainer {
2626
class MessageContainer(
2727
msgFn: => Message,
2828
val pos: SourcePosition,
29-
val level: Int,
30-
val explanation: String
29+
val level: Int
3130
) extends Exception with interfaces.Diagnostic {
3231
import MessageContainer._
3332
private var myMsg: String = null

src/dotty/tools/dotc/reporting/diagnostic/messages.scala

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,59 +17,51 @@ object messages {
1717
// `MessageContainer`s to be consumed by `Reporter` ---------------------- //
1818
class Error(
1919
msgFn: => Message,
20-
pos: SourcePosition,
21-
explanation: String = ""
22-
) extends MessageContainer(msgFn, pos, ERROR, explanation)
20+
pos: SourcePosition
21+
) extends MessageContainer(msgFn, pos, ERROR)
2322

2423
class Warning(
2524
msgFn: => Message,
26-
pos: SourcePosition,
27-
explanation: String = ""
28-
) extends MessageContainer(msgFn, pos, WARNING, explanation)
25+
pos: SourcePosition
26+
) extends MessageContainer(msgFn, pos, WARNING)
2927

3028
class Info(
3129
msgFn: => Message,
32-
pos: SourcePosition,
33-
explanation: String = ""
34-
) extends MessageContainer(msgFn, pos, INFO, explanation)
30+
pos: SourcePosition
31+
) extends MessageContainer(msgFn, pos, INFO)
3532

3633
abstract class ConditionalWarning(
3734
msgFn: => Message,
38-
pos: SourcePosition,
39-
explanation: String = ""
40-
) extends Warning(msgFn, pos, explanation) {
35+
pos: SourcePosition
36+
) extends Warning(msgFn, pos) {
4137
def enablingOption(implicit ctx: Context): Setting[Boolean]
4238
}
4339

4440
class FeatureWarning(
4541
msgFn: => Message,
46-
pos: SourcePosition,
47-
explanation: String = ""
48-
) extends ConditionalWarning(msgFn, pos, explanation) {
42+
pos: SourcePosition
43+
) extends ConditionalWarning(msgFn, pos) {
4944
def enablingOption(implicit ctx: Context) = ctx.settings.feature
5045
}
5146

5247
class UncheckedWarning(
5348
msgFn: => Message,
54-
pos: SourcePosition,
55-
explanation: String = ""
56-
) extends ConditionalWarning(msgFn, pos, explanation) {
49+
pos: SourcePosition
50+
) extends ConditionalWarning(msgFn, pos) {
5751
def enablingOption(implicit ctx: Context) = ctx.settings.unchecked
5852
}
5953

6054
class DeprecationWarning(
6155
msgFn: => Message,
62-
pos: SourcePosition,
63-
explanation: String = ""
64-
) extends ConditionalWarning(msgFn, pos, explanation) {
56+
pos: SourcePosition
57+
) extends ConditionalWarning(msgFn, pos) {
6558
def enablingOption(implicit ctx: Context) = ctx.settings.deprecation
6659
}
6760

6861
class MigrationWarning(
6962
msgFn: => Message,
70-
pos: SourcePosition,
71-
explanation: String = ""
72-
) extends ConditionalWarning(msgFn, pos, explanation) {
63+
pos: SourcePosition
64+
) extends ConditionalWarning(msgFn, pos) {
7365
def enablingOption(implicit ctx: Context) = ctx.settings.migration
7466
}
7567

0 commit comments

Comments
 (0)