diff --git a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala index 0df893b7d6fd..ea8ba39d73ca 100644 --- a/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala +++ b/compiler/src/dotty/tools/dotc/reporting/ErrorMessageID.scala @@ -1,12 +1,16 @@ package dotty.tools.dotc.reporting -/** Unique IDs identifying the messages +////////////////////////////////////////////////////////////////////////// +// IMPORTANT // +// Only add new IDs at end of the enumeration list and never remove IDs // +////////////////////////////////////////////////////////////////////////// + +/** Unique IDs identifying the messages, this will be used to reference documentation online. + * * @param isActive Whether or not the compile still emits this ErrorMessageID **/ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMessageID]: - // IMPORTANT: Add new IDs only at the end and never remove IDs - case LazyErrorId // // errorNumber: -2 case NoExplanationID // errorNumber: -1 case EmptyCatchOrFinallyBlockID extends ErrorMessageID(isActive = false) // errorNumber: 0 @@ -19,8 +23,8 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case TypeMismatchID // errorNumber: 7 case NotAMemberID // errorNumber: 8 case EarlyDefinitionsNotSupportedID // errorNumber: 9 - case TopLevelImplicitClassID extends ErrorMessageID(isActive = false) // errorNumber: 10 - case ImplicitCaseClassID // errorNumber: 11 + case TopLevelImplicitClassID extends ErrorMessageID(isActive = false) // errorNumber: 10 + case ImplicitCaseClassID // errorNumber: 11 case ImplicitClassPrimaryConstructorArityID // errorNumber: 12 case ObjectMayNotHaveSelfTypeID // errorNumber: 13 case TupleTooLongID extends ErrorMessageID(isActive = false) // errorNumber: 14 @@ -97,7 +101,7 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case FunctionTypeNeedsNonEmptyParameterListID // errorNumber: 85 case WrongNumberOfParametersID // errorNumber: 86 case DuplicatePrivateProtectedQualifierID // errorNumber: 87 - case ExpectedStartOfTopLevelDefinitionID // errorNumber: 88 + case ExpectedStartOfTopLevelDefinitionID // errorNumber: 88 case MissingReturnTypeWithReturnStatementID // errorNumber: 89 case NoReturnFromInlineableID // errorNumber: 90 case ReturnOutsideMethodDefinitionID // errorNumber: 91 @@ -180,12 +184,12 @@ enum ErrorMessageID(val isActive: Boolean = true) extends java.lang.Enum[ErrorMe case ImplicitSearchTooLargeID // errorNumber: 168 case TargetNameOnTopLevelClassID // errorNumber: 169 - def errorNumber = ordinal - 2 + def errorNumber = ordinal - 1 object ErrorMessageID: def fromErrorNumber(n: Int): Option[ErrorMessageID] = - val enumId = n + 2 - if enumId >= 2 && enumId < ErrorMessageID.values.length then + val enumId = n + 1 + if enumId >= 1 && enumId < ErrorMessageID.values.length then Some(fromOrdinal(enumId)) else None diff --git a/compiler/src/dotty/tools/dotc/reporting/Message.scala b/compiler/src/dotty/tools/dotc/reporting/Message.scala index 830516a2ebfd..77e1336a990c 100644 --- a/compiler/src/dotty/tools/dotc/reporting/Message.scala +++ b/compiler/src/dotty/tools/dotc/reporting/Message.scala @@ -43,7 +43,7 @@ object Message { * Instead use the `persist` method to create an instance that does not keep a * reference to these contexts. * - * @param errorId a unique id identifying the message, this will later be + * @param errorId a unique id identifying the message, this will be * used to reference documentation online */ abstract class Message(val errorId: ErrorMessageID) { self => diff --git a/compiler/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala b/compiler/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala deleted file mode 100644 index deae96d4168f..000000000000 --- a/compiler/test/dotty/tools/dotc/reporting/TestMessageLaziness.scala +++ /dev/null @@ -1,29 +0,0 @@ -package dotty.tools -package dotc -package reporting - -import org.junit.Test -import core.Contexts._ - -class TestMessageLaziness extends DottyTest { - ctx = ctx.fresh.setReporter(new NonchalantReporter) - - class NonchalantReporter(using Context) extends Reporter - with UniqueMessagePositions with HideNonSensicalMessages { - def doReport(dia: Diagnostic)(using Context) = ??? - - override def report(dia: Diagnostic)(using Context) = () - } - - case class LazyError() extends Message(ErrorMessageID.LazyErrorId) { - val kind = MessageKind.NoKind - def msg = throw new Error("Didn't stay lazy.") - def explain = "" - } - - @Test def assureLazy = - report.error(LazyError()) - - @Test def assureLazyExtendMessage = - report.errorOrMigrationWarning(LazyError(), from = config.SourceVersion.future) -}