Skip to content

Commit 199c516

Browse files
authored
Merge pull request #15271 from dotty-staging/remove-LazyErrorId
Remove ErrorMessageID.LazyErrorId and improve doc
2 parents 4518be0 + 825d92e commit 199c516

File tree

3 files changed

+11
-36
lines changed

3 files changed

+11
-36
lines changed

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

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package dotty.tools.dotc.reporting
22

3-
/** Unique IDs identifying the messages
3+
//////////////////////////////////////////////////////////////////////////
4+
// IMPORTANT //
5+
// Only add new IDs at end of the enumeration list and never remove IDs //
6+
//////////////////////////////////////////////////////////////////////////
7+
8+
/** Unique IDs identifying the messages, this will be used to reference documentation online.
9+
*
410
* @param isActive Whether or not the compile still emits this ErrorMessageID
511
**/
612
enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMessageID]:
713

8-
// IMPORTANT: Add new IDs only at the end and never remove IDs
9-
case LazyErrorId // // errorNumber: -2
1014
case NoExplanationID // errorNumber: -1
1115

1216
case EmptyCatchOrFinallyBlockID extends ErrorMessageID(isActive = false) // errorNumber: 0
@@ -180,12 +184,12 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe
180184
case ImplicitSearchTooLargeID // errorNumber: 168
181185
case TargetNameOnTopLevelClassID // errorNumber: 169
182186

183-
def errorNumber = ordinal - 2
187+
def errorNumber = ordinal - 1
184188

185189
object ErrorMessageID:
186190
def fromErrorNumber(n: Int): Option[ErrorMessageID] =
187-
val enumId = n + 2
188-
if enumId >= 2 && enumId < ErrorMessageID.values.length then
191+
val enumId = n + 1
192+
if enumId >= 1 && enumId < ErrorMessageID.values.length then
189193
Some(fromOrdinal(enumId))
190194
else
191195
None

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ object Message {
4343
* Instead use the `persist` method to create an instance that does not keep a
4444
* reference to these contexts.
4545
*
46-
* @param errorId a unique id identifying the message, this will later be
46+
* @param errorId a unique id identifying the message, this will be
4747
* used to reference documentation online
4848
*/
4949
abstract class Message(val errorId: ErrorMessageID) { self =>

compiler/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala

-29
This file was deleted.

0 commit comments

Comments
 (0)