Skip to content

Commit 7c76651

Browse files
committed
Check if .jar exists first
1 parent 8b5bf32 commit 7c76651

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

compiler/src/dotty/tools/dotc/Driver.scala

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,24 +89,23 @@ class Driver {
8989
// Resolve classpath and class names of tasty files
9090
val (classPaths, classNames) = fileNames0.flatMap { name =>
9191
val path = Paths.get(name)
92-
if name.endsWith(".jar") then
92+
if !name.endsWith(".jar") && !name.endsWith(".tasty") then // is class name
93+
("", name) :: Nil // TODO remove this case. We cannot rely on an expected tasty file beeing loaded.
94+
else if !Files.exists(path) then
95+
report.error(s"File does not exist: $name")
96+
Nil
97+
else if name.endsWith(".jar") then
9398
new dotty.tools.io.Jar(File(name)).toList.collect {
9499
case e if e.getName.endsWith(".tasty") =>
95100
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
96101
}
97-
else if (!name.endsWith(".tasty"))
98-
("", name) :: Nil
99-
else if Files.exists(path) then
100-
TastyFileUtil.getClassName(path) match {
101-
case Some(res) => res:: Nil
102+
else
103+
assert(name.endsWith(".tasty"))
104+
TastyFileUtil.getClassName(path) match
105+
case Some(res) => res :: Nil
102106
case _ =>
103107
report.error(s"Could not load classname from: $name")
104108
Nil
105-
}
106-
else {
107-
report.error(s"File does not exist: $name")
108-
Nil
109-
}
110109
}.unzip
111110
val ctx1 = ctx0.fresh
112111
val classPaths1 = classPaths.distinct.filter(_ != "")

0 commit comments

Comments
 (0)