From 223f32b7658a77fb2ad6b30ad247c0e27204b558 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 5 Apr 2017 01:55:52 +0200 Subject: DirectoryClassPath: handle directory being removed under us `dir.listFiles` will return null if called on a directory that no longer exists, somehow partest triggers that. --- .../tools/dotc/classpath/DirectoryClassPath.scala | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala index 94a6ad585..1ed233ed7 100644 --- a/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala +++ b/compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala @@ -99,21 +99,23 @@ trait JFileDirectoryLookup[FileEntryType <: ClassRepresentation] extends Directo case None => dir.listFiles() } - // Sort by file name for stable order of directory .class entries in package scope. - // This gives stable results ordering of base type sequences for unrelated classes - // with the same base type depth. - // - // Notably, this will stably infer`Product with Serializable` - // as the type of `case class C(); case class D(); List(C(), D()).head`, rather than the opposite order. - // On Mac, the HFS performs this sorting transparently, but on Linux the order is unspecified. - // - // Note this behaviour can be enabled in javac with `javac -XDsortfiles`, but that's only - // intended to improve determinism of the compiler for compiler hackers. - java.util.Arrays.sort(listing, - new java.util.Comparator[File] { - def compare(o1: File, o2: File) = o1.getName.compareTo(o2.getName) - }) - listing + if (listing != null) { + // Sort by file name for stable order of directory .class entries in package scope. + // This gives stable results ordering of base type sequences for unrelated classes + // with the same base type depth. + // + // Notably, this will stably infer`Product with Serializable` + // as the type of `case class C(); case class D(); List(C(), D()).head`, rather than the opposite order. + // On Mac, the HFS performs this sorting transparently, but on Linux the order is unspecified. + // + // Note this behaviour can be enabled in javac with `javac -XDsortfiles`, but that's only + // intended to improve determinism of the compiler for compiler hackers. + java.util.Arrays.sort(listing, + new java.util.Comparator[File] { + def compare(o1: File, o2: File) = o1.getName.compareTo(o2.getName) + }) + listing + } else Array() } protected def getName(f: File): String = f.getName protected def toAbstractFile(f: File): AbstractFile = new PlainFile(new scala.reflect.io.File(f)) -- cgit v1.2.3