Message

dotty.tools.dotc.reporting.Message$
See theMessage companion class
object Message

Tips for error message generation

  • You can use the em interpolator for error messages. It's defined in core.Decorators.
  • You can also use a simple string argument for error or warning (not for the other variants), but the string should not be interpolated or composed of objects that require a Context for evaluation.
  • When embedding interpolated substrings defined elsewhere in error messages, use i and make sure they are defined as def's instead of vals. That way, the possibly expensive interpolation will performed only in the case where the message is eventually printed. Note: At least during typer, it's common for messages to be discarded without being printed. Also, by making them defs, you ensure that they will be evaluated in the Message context, which makes formatting safer and more robust.
  • For common messages, or messages that might require explanation, prefer defining a new Message class in file messages.scala and use that instead. The advantage is that these messages have unique IDs that can be referenced elsewhere.

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Message.type

Members list

Value members

Concrete methods

def rewriteNotice(what: String, version: SourceVersion | Null, options: String)(using Context): String