Skip to content

Commit 63c87cf

Browse files
committed
Fix #15055
1 parent b1f00a7 commit 63c87cf

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

compiler/src/dotty/tools/io/VirtualFile.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
package dotty.tools.io
77

88
import scala.language.unsafeNulls
9-
9+
import java.nio.file.Paths
1010
import java.io.{ ByteArrayInputStream, ByteArrayOutputStream, InputStream, OutputStream }
1111

1212
/** This class implements an in-memory file.
@@ -36,7 +36,7 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF
3636
* @return the created virtual file
3737
*/
3838
def this(path: String, content: Array[Byte]) = {
39-
this(VirtualFile.nameOf(path), path)
39+
this(Paths.get(path).getFileName().toString(), path)
4040
this.content = content
4141
}
4242

@@ -104,7 +104,3 @@ class VirtualFile(val name: String, override val path: String) extends AbstractF
104104
*/
105105
def lookupNameUnchecked(name: String, directory: Boolean): AbstractFile = unsupported()
106106
}
107-
object VirtualFile:
108-
private def nameOf(path: String): String =
109-
val i = path.lastIndexOf('/')
110-
if i >= 0 && i < path.length - 1 then path.substring(i + 1) else path

0 commit comments

Comments
 (0)