diff --git a/compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala index 8a7095b21dd3..df58f4ea7ccf 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/PositionPickler.scala @@ -47,7 +47,12 @@ class PositionPickler(pickler: TastyPickler, addrOfTree: untpd.Tree => Addr) { def pickleSource(source: SourceFile): Unit = { buf.writeInt(SOURCE) - buf.writeInt(pickler.nameBuffer.nameIndex(source.path.toTermName).index) + val pathName = source.path + val path = java.nio.file.Paths.get(pathName.toString).toAbsolutePath().normalize() + val cwd = java.nio.file.Paths.get("").toAbsolutePath().normalize() + val relativePath = (cwd.relativize(path)) + assert(!relativePath.isAbsolute) + buf.writeInt(pickler.nameBuffer.nameIndex(relativePath.toString.toTermName).index) } /** True if x's position shouldn't be reconstructed automatically from its initial span