@@ -231,11 +231,29 @@ trait MessageRendering {
231
231
if origin.nonEmpty then
232
232
addHelp(" origin=" )(origin)
233
233
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
+ */
235
253
def messageAndPos (dia : Diagnostic )(using Context ): String = {
236
254
import dia .*
237
255
val pos1 = pos.nonInlined
238
- val inlineStack = pos.inlinePosStack.filterNot(pos1.coincidesWith(_ ))
256
+ val inlineStack = pos.inlinePosStack.filterNot(_.contains(pos1 ))
239
257
val maxLineNumber =
240
258
if pos.exists then (pos1 :: inlineStack).map(_.endLine).max + 1
241
259
else 0
@@ -256,7 +274,6 @@ trait MessageRendering {
256
274
val posString = posStr(adjusted, msg, diagnosticLevel(dia))
257
275
if (posString.nonEmpty) sb.append(posString).append(EOL )
258
276
if (pos.exists) {
259
- val pos1 = pos.nonInlined
260
277
if (pos1.exists && pos1.source.file.exists) {
261
278
val readjusted =
262
279
if pos1 == pos then adjusted
0 commit comments