Message

dotty.tools.dotc.reporting.Message
See theMessage companion object
abstract class Message(val errorId: ErrorMessageID)(using x$2: Context)

A Message contains all semantic information necessary to easily comprehend what caused the message to be logged. Each message can be turned into a Diagnostic which contains the log level and can later be consumed by a subclass of Reporter. However, the error position is only part of Diagnostic, not Message.

NOTE: you should not persist a message directly, because most messages take an implicit Context and these contexts weigh in at about 4mb per instance. Therefore, persisting these will result in a memory leak.

Instead use the persist method to create an instance that does not keep a reference to these contexts.

Value parameters

errorId

a unique id identifying the message, this will be used to reference documentation online Messages modify the rendendering of interpolated strings in several ways:

  1. The size of the printed code is limited with a MessafeLimiter. If the message would get too large or too deeply nested, a ... is printed instead.
  2. References to module classes are prefixed with object for better recogniability.
  3. A where clause is sometimes added which contains the following additional explanations:
    • Rerences are disambiguated: If a message contains occurrences of the same identifier representing different symbols, the duplicates are printed with superscripts and the where-clause explains where each symbol is located.
    • Uninstantiated variables are explained in the where-clause with additional info about their bounds.
    • Skolems are explained with additional info about their underlying type. Messages inheriting from the NoDisambiguation trait or returned from the noDisambiguation() method skip point (3) above. This makes sense if the message already exolains where different occurrences of the same identifier are located. Examples are NamingMsgs such as double definition errors, overriding errors, and ambiguous implicit errors. We consciously made the design decision to disambiguate by default and disable disambiguation as an opt-in. The reason is that one usually does not consider all fine-grained details when writing an error message. If disambiguation is the default, some tests will show where clauses that look too noisy and that then can be disabled when needed. But if silence is the default, one usually does not realize that better info could be obtained by turning disambiguation on.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class CyclicMsg
class NamingMsg
class NotFoundMsg
class MissingIdent
class NotAMember
class ReferenceMsg
class NotClassType
class NotConstant
class TypeMismatch
class SyntaxMsg
class TypeMsg
class NotAPath
Show all
Self type

Members list

Value members

Abstract methods

The kind of the error message, e.g. "Syntax" or "Type Mismatch". This will be printed as "$kind Error", "$kind Warning", etc, on the first line of the message.

The kind of the error message, e.g. "Syntax" or "Type Mismatch". This will be printed as "$kind Error", "$kind Warning", etc, on the first line of the message.

Attributes

Concrete methods

A list of actions attached to this message to address the issue this message represents.

A list of actions attached to this message to address the issue this message represents.

Attributes

def append(suffix: => String): Message
def appendExplanation(suffix: => String): Message

Does this message have an explanation? This is normally the same as explain.nonEmpty but can be overridden if we need a way to return true without actually calling the explain method.

Does this message have an explanation? This is normally the same as explain.nonEmpty but can be overridden if we need a way to return true without actually calling the explain method.

Attributes

A message is non-sensical if it contains references to internally generated error types. Normally we want to suppress error messages referring to types like this because they look weird and are normally follow-up errors to something that was diagnosed before.

A message is non-sensical if it contains references to internally generated error types. Normally we want to suppress error messages referring to types like this because they look weird and are normally follow-up errors to something that was diagnosed before.

Attributes

def mapMsg(f: String => String): Message

The implicit Context in messages is a large thing that we don't want persisted. This method gets around that by duplicating the message, forcing its msg and explanation vals and dropping the implicit context that was captured in the original message.

The implicit Context in messages is a large thing that we don't want persisted. This method gets around that by duplicating the message, forcing its msg and explanation vals and dropping the implicit context that was captured in the original message.

Attributes

def prepend(prefix: => String): Message

Override with true for messages that should always be shown even if their position overlaps another message of a different class. On the other hand multiple messages of the same class with overlapping positions will lead to only a single message of that class to be issued.

Override with true for messages that should always be shown even if their position overlaps another message of a different class. On the other hand multiple messages of the same class with overlapping positions will lead to only a single message of that class to be issued.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any
def withoutDisambiguation(): this.type

Concrete fields

lazy val explanation: String

The explanation to report. tags are filtered out

The explanation to report. tags are filtered out

Attributes

lazy val message: String

The message to report. tags are filtered out

The message to report. tags are filtered out

Attributes