From 031847b8b445df665f777916e0649b902b02a2fb Mon Sep 17 00:00:00 2001 From: Solal Pirelli Date: Fri, 31 Jul 2026 22:22:36 +0200 Subject: [PATCH] Stop interning all PlainFile paths --- compiler/src/dotty/tools/io/JarArchive.scala | 2 +- compiler/src/dotty/tools/io/PlainFile.scala | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/src/dotty/tools/io/JarArchive.scala b/compiler/src/dotty/tools/io/JarArchive.scala index a8973ee19b6f..b95ef2937a9b 100644 --- a/compiler/src/dotty/tools/io/JarArchive.scala +++ b/compiler/src/dotty/tools/io/JarArchive.scala @@ -12,7 +12,7 @@ import scala.jdk.CollectionConverters.* class JarArchive private (underlying: Path, root: Directory) extends PlainDirectory(root) { def close(): Unit = this.synchronized(jpath.getFileSystem().close()) - override val path: String = underlying.path + override lazy val path: String = underlying.path override def ext: FileExtension = underlying.ext override def exists: Boolean = jpath.getFileSystem().isOpen() && super.exists diff --git a/compiler/src/dotty/tools/io/PlainFile.scala b/compiler/src/dotty/tools/io/PlainFile.scala index 49228e62ef67..bb69b09a7870 100644 --- a/compiler/src/dotty/tools/io/PlainFile.scala +++ b/compiler/src/dotty/tools/io/PlainFile.scala @@ -27,19 +27,18 @@ class PlainFile(givenPath: Path) extends AbstractFile { override def name: String = givenPath.name - // Interned for fast hashcode and equals - override val path: String = givenPath.normalize.path.intern + override lazy val path: String = givenPath.normalize.path override def container: Option[AbstractFile] = Some(new PlainFile(givenPath.parent)) override def input: InputStream = givenPath.toFile.inputStream() override def output: OutputStream = givenPath.toFile.outputStream() override def toURL: Option[URL] = Some(jpath.toUri.toURL) - override def hashCode(): Int = System.identityHashCode(path) - override def equals(that: Any): Boolean = that match { + override def hashCode(): Int = path.hashCode + override def equals(that: Any): Boolean = (this `eq` that.asInstanceOf[Object]) || (that match { case x: PlainFile => path `eq` x.path case _ => false - } + }) /** Is this abstract file a directory? */ override val isDirectory: Boolean = givenPath.isDirectory // cached for performance on Windows