Skip to content

Commit 8817b15

Browse files
committed
Make ErrorMessageID a Scala enum
1 parent 95aa46e commit 8817b15

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ trait MessageRendering {
119119
else s"${pos.source.file.toString}: offset ${pos.start} (missing source file)"
120120
val errId =
121121
if (message.errorId ne ErrorMessageID.NoExplanationID) {
122-
val errorNumber = message.errorId.errorNumber()
122+
val errorNumber = message.errorId.errorNumber
123123
s"[E${"0" * (3 - errorNumber.toString.length) + errorNumber}] "
124124
} else ""
125125
val kind =

compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.java renamed to compiler/src/dotty/tools/dotc/reporting/diagnostic/ErrorMessageID.scala

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package dotty.tools.dotc.reporting.diagnostic;
1+
package dotty.tools.dotc.reporting.diagnostic
22

33
/** Unique IDs identifying the messages */
4-
public enum ErrorMessageID {
5-
6-
// IMPORTANT: Add new IDs only at the end and never remove IDs
4+
enum ErrorMessageID {
75

6+
// IMPORTANT: Add new IDs only at the end and never remove IDs
7+
case
88
LazyErrorId, // // errorNumber: -2
99
NoExplanationID, // errorNumber: -1
1010

@@ -146,10 +146,6 @@ public enum ErrorMessageID {
146146
StableIdentPatternID,
147147
StaticFieldsShouldPrecedeNonStaticID,
148148
IllegalSuperAccessorID
149-
;
150-
151-
public int errorNumber() {
152-
return ordinal() - 2;
153-
}
154149

150+
def errorNumber = ordinal - 2
155151
}

0 commit comments

Comments
 (0)