Skip to content
Merged
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
10 changes: 5 additions & 5 deletions compiler/src/dotty/tools/dotc/util/SourcePosition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ extends interfaces.SourcePosition with Showable {
source.content.slice(source.startOfLine(start), source.nextLine(end))

/** The lines of the position */
def lines: List[Int] = {
def lines: Range = {
val startOffset = source.offsetToLine(start)
val endOffset = source.offsetToLine(end + 1)
if (startOffset >= endOffset) line :: Nil
else (startOffset until endOffset).toList
val endOffset = source.offsetToLine(end - 1) // -1 to drop a line if no chars in it form part of the position
if (startOffset >= endOffset) line to line
else startOffset to endOffset
}

def lineOffsets: List[Int] =
lines.map(source.lineToOffset(_))
lines.toList.map(source.lineToOffset(_))

def beforeAndAfterPoint: (List[Int], List[Int]) =
lineOffsets.partition(_ <= point)
Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i7028.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Test {
"abc"
.foo // error

"abc"
.bar.baz // error

"abc"
.bar // error
.baz
}