diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-05-15 07:29:13 -0700 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-05-15 07:29:13 -0700 |
commit | c587bdf0db0dc88c8e6cc6db109a7fd4a368e8f1 (patch) | |
tree | 6f98af15d439be1f8383b75a851e26574bee92a5 | |
parent | 6a3efe3b3e83c37182268f0e0bab9acc69653115 (diff) | |
parent | b0758f5cb9d966b940933d48bdbb45d17a80de66 (diff) | |
download | scala-c587bdf0db0dc88c8e6cc6db109a7fd4a368e8f1.tar.gz scala-c587bdf0db0dc88c8e6cc6db109a7fd4a368e8f1.tar.bz2 scala-c587bdf0db0dc88c8e6cc6db109a7fd4a368e8f1.zip |
Merge pull request #2503 from paulp/issue/6039
SI-6039 Harden against irrelevant filesystem details
-rw-r--r-- | src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala | 8 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/util/ClassPath.scala | 2 | ||||
-rw-r--r-- | test/files/run/t6039.scala | 18 |
3 files changed, 26 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala index 250feb69bf..98fb6bd0ef 100644 --- a/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala +++ b/src/compiler/scala/tools/nsc/symtab/SymbolLoaders.scala @@ -234,10 +234,14 @@ abstract class SymbolLoaders { } } if (!root.isEmptyPackageClass) { + // Only enter packages which contain a class or a non-empty package for (pkg <- classpath.packages) { - enterPackage(root, pkg.name, new PackageLoader(pkg)) + if (pkg.isEmptyOfClassfiles) { + log(s"Discarding $root/$pkg as it contains no classfiles.") + } + else + enterPackage(root, pkg.name, new PackageLoader(pkg)) } - openPackageModule(root) } } diff --git a/src/compiler/scala/tools/nsc/util/ClassPath.scala b/src/compiler/scala/tools/nsc/util/ClassPath.scala index 7f9b81e1ec..536a281e6c 100644 --- a/src/compiler/scala/tools/nsc/util/ClassPath.scala +++ b/src/compiler/scala/tools/nsc/util/ClassPath.scala @@ -211,6 +211,8 @@ abstract class ClassPath[T] { def validPackage(name: String) = (name != "META-INF") && (name != "") && (name.charAt(0) != '.') def validSourceFile(name: String) = endsScala(name) || endsJava(name) + def isEmptyOfClassfiles: Boolean = classes.isEmpty && packages.forall(_.isEmptyOfClassfiles) + /** * Find a ClassRep given a class name of the form "package.subpackage.ClassName". * Does not support nested classes on .NET diff --git a/test/files/run/t6039.scala b/test/files/run/t6039.scala new file mode 100644 index 0000000000..9d811b0634 --- /dev/null +++ b/test/files/run/t6039.scala @@ -0,0 +1,18 @@ +import scala.tools.partest._ + +object Test extends StoreReporterDirectTest { + private def compileCode(): Boolean = { + new java.io.File("util") mkdirs + val classpath = List(sys.props("partest.lib"), ".") mkString sys.props("path.separator") + log(s"classpath = $classpath") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(packageCode) + } + def code = ??? + def packageCode = """ +package scala.bippy +class A { new util.Random() } +""" + def show(): Unit = { + assert(compileCode(), filteredInfos take 1 mkString "") + } +} |