diff --git a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala index 9fa949fd2cdf..808e1c19065f 100644 --- a/compiler/src/dotty/tools/dotc/util/SourcePosition.scala +++ b/compiler/src/dotty/tools/dotc/util/SourcePosition.scala @@ -22,7 +22,7 @@ extends interfaces.SourcePosition with Showable { def point: Int = span.point - def line: Int = if (source.file.exists) source.offsetToLine(point) else -1 + def line: Int = if (source.content().length != 0) source.offsetToLine(point) else -1 /** Extracts the lines from the underlying source file as `Array[Char]`*/ def linesSlice: Array[Char] =