Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions compiler/src/dotty/tools/dotc/cc/SepCheck.scala
Original file line number Diff line number Diff line change
Expand Up @@ -461,10 +461,7 @@ class SepCheck(checker: CheckCaptures.CheckerAPI) extends tpd.TreeTraverser:
*/
def consumeError(ref: Capability, loc: (SrcPos, TypeRole), pos: SrcPos)(using Context): Unit =
val (locPos, role) = loc
report.error(
em"""Separation failure: Illegal access to $ref, which was ${role.howConsumed}
|on line ${locPos.line + 1} and therefore is no longer available.""",
pos)
report.error(reporting.UseAfterConsume(ref, locPos.sourcePos, pos.sourcePos, role.howConsumed), pos)

/** Report a failure where a capability is consumed in a loop.
* @param ref the capability
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/reporting/Diagnostic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ class Diagnostic(
msg.message.replaceAll("\u001B\\[[;\\d]*m", "")
override def diagnosticRelatedInformation: JList[interfaces.DiagnosticRelatedInformation] =
Collections.emptyList()

override def toString: String = s"$getClass at $pos L${pos.line+1}: $message"
end Diagnostic

18 changes: 18 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ object Message:
super.toText(sym)
end Printer

/** A part of a multi-span message, associating text with a source position.
* @param text the message text for this part
* @param srcPos the source position where this part applies
* @param isPrimary whether this is the primary message (true) or a secondary note (false)
*/
case class MessagePart(text: String, srcPos: util.SourcePosition, isPrimary: Boolean)

end Message

/** A `Message` contains all semantic information necessary to easily
Expand Down Expand Up @@ -370,6 +377,17 @@ abstract class Message(val errorId: ErrorMessageID)(using Context) { self =>
*/
protected def explain(using Context): String

/** Optional leading text to be displayed before the source snippet.
* If present along with parts, triggers multi-span rendering.
*/
def leading(using Context): Option[String] = None

/** Optional list of message parts for multi-span error messages.
* Each part associates text with a source position and indicates
* whether it's a primary message or a secondary note.
*/
def parts(using Context): List[MessagePart] = Nil

/** What gets printed after the message proper */
protected def msgPostscript(using Context): String =
if ctx eq NoContext then ""
Expand Down
Loading
Loading