Skip to content
Closed
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
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/inlines/Inliner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ class Inliner(val call: tpd.Tree)(using Context):
// The context in which we report should still use the existing context reporter
val ctxOrigReporter = ctxToReport.fresh.setReporter(ctx.reporter)
inContext(ctxOrigReporter) {
report.error(message, callToReport.srcPos)
report.error(new reporting.Custom(message), callToReport.srcPos)
}
case _ =>
}
Expand Down
9 changes: 9 additions & 0 deletions compiler/src/dotty/tools/dotc/reporting/Message.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ abstract class Message(val errorId: ErrorMessageID) { self =>
override def toString = msg
}

/* a message generated by an inlined call to compiletime.error method */
class Custom(_msg: String) extends Message(ErrorMessageID.NoExplanationID) {
def msg: String = _msg
def explain: String = ""
val kind: MessageKind = MessageKind.CustomCompiletime

override def toString(): String = msg
}

/** The fallback `Message` containing no explanation and having no `kind` */
class NoExplanation(msgFn: => String) extends Message(ErrorMessageID.NoExplanationID) {
def msg: String = msgFn
Expand Down
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/reporting/MessageKind.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ enum MessageKind:
case MatchCaseUnreachable
case Compatibility
case PotentialIssue
case CustomCompiletime

/** Human readable message that will end up being shown to the user.
* NOTE: This is only used in the situation where you have multiple words
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ trait MessageRendering {
s"[E${"0" * (3 - errorNumber.toString.length) + errorNumber}] "
else ""
val kind =
if (message.kind == MessageKind.NoKind) then diagnosticString
if (message.kind == MessageKind.NoKind || message.kind == MessageKind.CustomCompiletime) then diagnosticString
else s"${message.kind.message} $diagnosticString"
val title =
if fileAndPos.isEmpty then s"$errId$kind:" // this happens in dotty.tools.repl.ScriptedTests // TODO add name of source or remove `:` (and update test files)
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@ trait Implicits:
case _ =>
tryConversion
}
if ctx.reporter.hasErrors
if (ctx.reporter.hasErrors && ctx.reporter.allErrors.exists(_.msg.kind != MessageKind.CustomCompiletime))
|| !cand.ref.symbol.isAccessibleFrom(cand.ref.prefix)
then
ctx.reporter.removeBufferedMessages
Expand Down