Skip to content

Commit 261e056

Browse files
committed
Minor syntax tweak
1 parent da91be8 commit 261e056

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -235,22 +235,21 @@ abstract class AbstractFile extends Iterable[AbstractFile] {
235235
file
236236
}
237237

238-
private def fileOrSubdirectoryNamed(name: String, isDir: Boolean): AbstractFile = {
239-
val lookup = lookupName(name, isDir)
240-
if (lookup != null) lookup
241-
else {
242-
// the optional exception may be thrown for symlinks, notably /tmp on MacOS.
243-
// isDirectory tests for existing directory. The default behavior is hypothetical isDirectory(jpath, FOLLOW_LINKS).
244-
try Files.createDirectories(jpath)
245-
catch { case _: FileAlreadyExistsException if Files.isDirectory(jpath) => }
246-
247-
// a race condition in creating the entry after the failed lookup may throw
248-
val path = jpath.resolve(name)
249-
if (isDir) Files.createDirectory(path)
250-
else Files.createFile(path)
251-
new PlainFile(new File(path))
238+
private def fileOrSubdirectoryNamed(name: String, isDir: Boolean): AbstractFile =
239+
lookupName(name, isDir) match {
240+
case null =>
241+
// the optional exception may be thrown for symlinks, notably /tmp on MacOS.
242+
// isDirectory tests for existing directory. The default behavior is hypothetical isDirectory(jpath, FOLLOW_LINKS).
243+
try Files.createDirectories(jpath)
244+
catch { case _: FileAlreadyExistsException if Files.isDirectory(jpath) => }
245+
246+
// a race condition in creating the entry after the failed lookup may throw
247+
val path = jpath.resolve(name)
248+
if (isDir) Files.createDirectory(path)
249+
else Files.createFile(path)
250+
new PlainFile(new File(path))
251+
case lookup => lookup
252252
}
253-
}
254253

255254
/**
256255
* Get the file in this directory with the given name,

0 commit comments

Comments
 (0)