Skip to content

Commit 7c41f18

Browse files
committed
Always use forward slash as path element separator in TASTy
1 parent 265a279 commit 7c41f18

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,15 @@ object SourceFile {
233233
// As we already check that the prefix matches, the special handling for
234234
// Windows is not needed.
235235

236-
refPath.relativize(sourcePath).toString
236+
// We also consistently use forward slashes as path element separators
237+
// for relative paths. If we didn't do that, it'd be impossible to parse
238+
// them back, as one would need to know whether they were created on Windows
239+
// and use both slashes as separators, or on other OS and use forward slash
240+
// as separator, backslash as file name character.
241+
242+
import scala.jdk.CollectionConverters._
243+
val path = refPath.relativize(sourcePath)
244+
path.iterator.asScala.mkString("/")
237245
else
238246
sourcePath.toString
239247
}

0 commit comments

Comments
 (0)