Skip to content

Commit 4d3f315

Browse files
Merge pull request #7518 from dotty-staging/fix-#7474
Use relative paths in position pickler
2 parents 7d50bdb + 698b61b commit 4d3f315

File tree

3 files changed

+3
-9
lines changed

3 files changed

+3
-9
lines changed

compiler/src/dotty/tools/dotc/core/Contexts.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ object Contexts {
239239
}
240240

241241
/** Sourcefile with given path name, memoized */
242-
def getSource(path: SourceFile.PathName): SourceFile = base.sourceNamed.get(path) match {
242+
def getSource(path: TermName): SourceFile = base.sourceNamed.get(path) match {
243243
case Some(source) =>
244244
source
245245
case None =>
@@ -685,7 +685,7 @@ object Contexts {
685685

686686
/** Sources that were loaded */
687687
val sources: mutable.HashMap[AbstractFile, SourceFile] = new mutable.HashMap[AbstractFile, SourceFile]
688-
val sourceNamed: mutable.HashMap[SourceFile.PathName, SourceFile] = new mutable.HashMap[SourceFile.PathName, SourceFile]
688+
val sourceNamed: mutable.HashMap[TermName, SourceFile] = new mutable.HashMap[TermName, SourceFile]
689689

690690
// Types state
691691
/** A table for hash consing unique types */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) {
4545

4646
def pickleSource(source: SourceFile): Unit = {
4747
buf.writeInt(SOURCE)
48-
buf.writeInt(pickler.nameBuffer.nameIndex(source.pathName).index)
48+
buf.writeInt(pickler.nameBuffer.nameIndex(source.path.toTermName).index)
4949
}
5050

5151
/** True if x's position shouldn't be reconstructed automatically from its initial span

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import java.io.IOException
99
import scala.internal.Chars._
1010
import Spans._
1111
import scala.io.Codec
12-
import core.Names.TermName
1312
import core.Contexts.Context
1413
import scala.annotation.internal.sharable
15-
import core.Decorators.PreNamedString
1614
import java.util.concurrent.atomic.AtomicInteger
1715
import scala.collection.mutable
1816

@@ -59,8 +57,6 @@ class SourceFile(val file: AbstractFile, computeContent: => Array[Char]) extends
5957
override def path: String = file.path
6058
override def jfile: Optional[JFile] = Optional.ofNullable(file.file)
6159

62-
def pathName: PathName = file.absolutePath.toTermName
63-
6460
override def equals(that: Any): Boolean =
6561
(this `eq` that.asInstanceOf[AnyRef]) || {
6662
that match {
@@ -202,8 +198,6 @@ object SourceFile {
202198

203199
implicit def fromContext(implicit ctx: Context): SourceFile = ctx.source
204200

205-
type PathName = TermName
206-
207201
def fromId(id: Int): SourceFile = sourceOfChunk(id >> ChunkSizeLog)
208202

209203
def virtual(name: String, content: String) = new SourceFile(new VirtualFile(name, content.getBytes), scala.io.Codec.UTF8)

0 commit comments

Comments
 (0)