@@ -231,11 +231,29 @@ trait MessageRendering {
231231 if origin.nonEmpty then
232232 addHelp(" origin=" )(origin)
233233
234- /** The whole message rendered from `msg` */
234+ /** The whole message rendered from `dia.msg`.
235+ *
236+ * For a position in an inline expansion, choose `pos1`
237+ * which is the most specific position in the call written
238+ * by the user. For a diagnostic at EOF, where the last char
239+ * of source text is a newline, adjust the position to render
240+ * before the newline, at the end of the last line of text.
241+ *
242+ * The rendering begins with a label and position (`posString`).
243+ * Then `sourceLines` with embedded caret `positionMarker`
244+ * and rendered message.
245+ *
246+ * Then an `Inline stack trace` showing context for inlined code.
247+ * Inlined positions are taken which don't contain `pos1`.
248+ * (That should probably be positions not contained by outermost.)
249+ * Note that position equality includes `outer` position;
250+ * usually we intend to test `contains` or `coincidesWith`.
251+ *
252+ */
235253 def messageAndPos (dia : Diagnostic )(using Context ): String = {
236254 import dia .*
237255 val pos1 = pos.nonInlined
238- val inlineStack = pos.inlinePosStack.filterNot(pos1.coincidesWith(_ ))
256+ val inlineStack = pos.inlinePosStack.filterNot(_.contains(pos1 ))
239257 val maxLineNumber =
240258 if pos.exists then (pos1 :: inlineStack).map(_.endLine).max + 1
241259 else 0
@@ -256,7 +274,6 @@ trait MessageRendering {
256274 val posString = posStr(adjusted, msg, diagnosticLevel(dia))
257275 if (posString.nonEmpty) sb.append(posString).append(EOL )
258276 if (pos.exists) {
259- val pos1 = pos.nonInlined
260277 if (pos1.exists && pos1.source.file.exists) {
261278 val readjusted =
262279 if pos1 == pos then adjusted
0 commit comments