Skip to content

Commit 38fb6a6

Browse files
committed
Filter pos by span not outer
1 parent 911f183 commit 38fb6a6

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

compiler/src/dotty/tools/dotc/reporting/MessageRendering.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ trait MessageRendering {
235235
def messageAndPos(dia: Diagnostic)(using Context): String = {
236236
import dia.*
237237
val pos1 = pos.nonInlined
238-
val inlineStack = pos.inlinePosStack.filter(_ != pos1)
238+
val inlineStack = pos.inlinePosStack.filterNot(pos1.coincidesWith(_))
239239
val maxLineNumber =
240240
if pos.exists then (pos1 :: inlineStack).map(_.endLine).max + 1
241241
else 0

compiler/src/dotty/tools/dotc/util/SourcePosition.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,16 @@ extends SrcPos, interfaces.SourcePosition, Showable:
1515

1616
def sourcePos(using Context) = this
1717

18-
/** Is `that` a source position contained in this source position ?
18+
/** Is `that` a source position contained in this source position?
1919
* `outer` is not taken into account. */
2020
def contains(that: SourcePosition): Boolean =
2121
this.source == that.source && this.span.contains(that.span)
2222

23+
/** Is `that` a source position that coincides with this source position?
24+
* `outer` is not taken into account. */
25+
def coincidesWith(that: SourcePosition): Boolean =
26+
this.source == that.source && this.span == that.span
27+
2328
def exists: Boolean = span.exists
2429

2530
def lineContent: String = source.lineContent(point)

0 commit comments

Comments
 (0)