Skip to content

Commit 010302a

Browse files
committed
Do not update source positions once initizlized
1 parent a28aee1 commit 010302a

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1399,7 +1399,7 @@ class TreeUnpickler(reader: TastyReader,
13991399
if (path.nonEmpty) {
14001400
val sourceFile = ctx.getSource(path)
14011401
posUnpicklerOpt match
1402-
case Some(posUnpickler) =>
1402+
case Some(posUnpickler) if !sourceFile.initizlized =>
14031403
sourceFile.setLineIndicesFromLineSizes(posUnpickler.lineSizes)
14041404
case _ =>
14051405
pickling.println(i"source change at $addr: $path")

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
144144
if lineIndicesCache eq null then
145145
lineIndicesCache = calculateLineIndicesFromContents()
146146
lineIndicesCache
147+
148+
def initizlized = lineIndicesCache != null
149+
147150
def setLineIndicesFromLineSizes(sizes: Array[Int]): Unit =
148151
val lines = sizes.length
149152
val indices = new Array[Int](lines + 1)

0 commit comments

Comments
 (0)