diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/io/AbstractFile.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ClassPath.scala | 24 |
2 files changed, 17 insertions, 13 deletions
diff --git a/src/compiler/scala/tools/nsc/io/AbstractFile.scala b/src/compiler/scala/tools/nsc/io/AbstractFile.scala index e0eb61486f..77c7ad0147 100644 --- a/src/compiler/scala/tools/nsc/io/AbstractFile.scala +++ b/src/compiler/scala/tools/nsc/io/AbstractFile.scala @@ -53,8 +53,10 @@ object AbstractFile { * @param file ... * @return ... */ - def getURL(url: URL): AbstractFile = - Option(url) collect { case url: URL if Path.isJarOrZip(url.getPath) => ZipArchive fromURL url } orNull + def getURL(url: URL): AbstractFile = { + if (url == null || !Path.isJarOrZip(url.getPath)) null + else ZipArchive fromURL url + } } /** diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index f0f3716782..0a8c54f297 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -8,8 +8,7 @@ package scala.tools.nsc package util import java.net.URL -import scala.collection.{ mutable, immutable } -import mutable.ListBuffer +import scala.collection.mutable.ListBuffer import io.{ File, Directory, Path, AbstractFile } import scala.tools.util.StringOps.splitWhere import Path.isJarOrZip @@ -289,15 +288,16 @@ class SourcePath[T](dir: AbstractFile, val context: ClassPathContext[T]) extends def asClasspathString = dir.path val sourcepaths: List[AbstractFile] = List(dir) - lazy val classes: List[ClassRep] = dir collect { - case f if !f.isDirectory && validSourceFile(f.name) => ClassRep(None, Some(f)) + lazy val classes: List[ClassRep] = dir flatMap { f => + if (f.isDirectory || !validSourceFile(f.name)) Nil + else List(ClassRep(None, Some(f))) } toList - lazy val packages: List[SourcePath[T]] = dir collect { - case f if f.isDirectory && validPackage(f.name) => new SourcePath[T](f, context) + lazy val packages: List[SourcePath[T]] = dir flatMap { f => + if (f.isDirectory && validPackage(f.name)) List(new SourcePath[T](f, context)) + else Nil } toList - override def toString() = "sourcepath: "+ dir.toString() } @@ -311,12 +311,14 @@ class DirectoryClassPath(val dir: AbstractFile, val context: ClassPathContext[Ab def asClasspathString = dir.path val sourcepaths: List[AbstractFile] = Nil - lazy val classes: List[ClassRep] = dir collect { - case f if !f.isDirectory && validClassFile(f.name) => ClassRep(Some(f), None) + lazy val classes: List[ClassRep] = dir flatMap { f => + if (f.isDirectory || !validClassFile(f.name)) Nil + else List(ClassRep(Some(f), None)) } toList - lazy val packages: List[DirectoryClassPath] = dir collect { - case f if f.isDirectory && validPackage(f.name) => new DirectoryClassPath(f, context) + lazy val packages: List[DirectoryClassPath] = dir flatMap { f => + if (f.isDirectory && validPackage(f.name)) List(new DirectoryClassPath(f, context)) + else Nil } toList override def toString() = "directory classpath: "+ dir |