aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/io
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 /compiler/src/dotty/tools/io
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?
Diffstat (limited to 'compiler/src/dotty/tools/io')
-rw-r--r--compiler/src/dotty/tools/io/ClassPath.scala13
1 files changed, 3 insertions, 10 deletions
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: _*)