aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2017-03-31 11:15:51 +0200
committerMartin Odersky <odersky@gmail.com>2017-03-31 11:15:51 +0200
commitf3707992ee2ed56ce754df8c0760fc3928f0317f (patch)
treea9d433e5e1ff9f6fec03254fed796660abb52b85
parent03f13046f0a6cde36cba2a9649aad8996ba7550a (diff)
downloaddotty-f3707992ee2ed56ce754df8c0760fc3928f0317f.tar.gz
dotty-f3707992ee2ed56ce754df8c0760fc3928f0317f.tar.bz2
dotty-f3707992ee2ed56ce754df8c0760fc3928f0317f.zip
Fix ClassfileParser
#2158 has uncovered flaws in the classfile parser. Matches that used to always miss led to code that made no sense. The function naming was terrible too, that's why nobody understood what was going on. `findSourceFile` to find the class file, seriously?
-rw-r--r--compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala2
-rw-r--r--compiler/src/dotty/tools/io/ClassPath.scala13
2 files changed, 4 insertions, 11 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
index bc140c26b..e0b233ce8 100644
--- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
+++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala
@@ -661,7 +661,7 @@ class ClassfileParser(
for (entry <- innerClasses.values) {
// create a new class member for immediate inner classes
if (entry.outerName == currentClassName) {
- val file = ctx.platform.classPath.findSourceFile(entry.externalName.toString) getOrElse {
+ val file = ctx.platform.classPath.findBinaryFile(entry.externalName.toString) getOrElse {
throw new AssertionError(entry.externalName)
}
enterClassAndModule(entry, file, entry.jflags)
diff --git a/compiler/src/dotty/tools/io/ClassPath.scala b/compiler/src/dotty/tools/io/ClassPath.scala
index 413d095c4..5e77c1b61 100644
--- a/compiler/src/dotty/tools/io/ClassPath.scala
+++ b/compiler/src/dotty/tools/io/ClassPath.scala
@@ -240,20 +240,13 @@ abstract class ClassPath {
def findClass(name: String): Option[AnyClassRep] =
name.splitWhere(_ == '.', doDropIndex = true) match {
case Some((pkg, rest)) =>
- val rep = packages find (_.name == pkg) flatMap (_ findClass rest)
- rep map {
- case x: AnyClassRep => x
- case x => throw new FatalError("Unexpected ClassRep '%s' found searching for name '%s'".format(x, name))
- }
+ packages find (_.name == pkg) flatMap (_ findClass rest)
case _ =>
classes find (_.name == name)
}
- def findSourceFile(name: String): Option[AbstractFile] =
- findClass(name) match {
- case Some(ClassRep(Some(x: AbstractFile), _)) => Some(x)
- case _ => None
- }
+ def findBinaryFile(name: String): Option[AbstractFile] =
+ findClass(name).flatMap(_.binary)
def sortString = join(split(asClasspathString).sorted: _*)