aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-04-05 01:55:52 +0200
committerGuillaume Martres <smarter@ubuntu.com>2017-04-11 16:04:31 +0200
commit223f32b7658a77fb2ad6b30ad247c0e27204b558 (patch)
tree94456b21bae6a8ebe0f89ee89b0e3af1a1223f42
parent2b04d2a96100fad5fc88b78b6b4094ae6ae25a37 (diff)
downloaddotty-223f32b7658a77fb2ad6b30ad247c0e27204b558.tar.gz
dotty-223f32b7658a77fb2ad6b30ad247c0e27204b558.tar.bz2
dotty-223f32b7658a77fb2ad6b30ad247c0e27204b558.zip
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.
-rw-r--r--compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala32
1 files 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))