Skip to content

Commit

Permalink
Do not update source positions once initizlized
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Jul 29, 2021
1 parent a28aee1 commit 010302a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1399,7 +1399,7 @@ class TreeUnpickler(reader: TastyReader,
if (path.nonEmpty) {
val sourceFile = ctx.getSource(path)
posUnpicklerOpt match
case Some(posUnpickler) =>
case Some(posUnpickler) if !sourceFile.initizlized =>
sourceFile.setLineIndicesFromLineSizes(posUnpickler.lineSizes)
case _ =>
pickling.println(i"source change at $addr: $path")
Expand Down
3 changes: 3 additions & 0 deletions compiler/src/dotty/tools/dotc/util/SourceFile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
if lineIndicesCache eq null then
lineIndicesCache = calculateLineIndicesFromContents()
lineIndicesCache

def initizlized = lineIndicesCache != null

def setLineIndicesFromLineSizes(sizes: Array[Int]): Unit =
val lines = sizes.length
val indices = new Array[Int](lines + 1)
Expand Down

0 comments on commit 010302a

Please sign in to comment.