Skip to content

Commit 8b5bf32

Browse files
committed
Avoid double errors when tasty file does not exist
There is no point trying to load the tasty file after we have emitted the error. Loading it only end up in a second error that shadows the root of the problem. Also improve readabllility of the error message.
1 parent 100931e commit 8b5bf32

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,23 +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"))
92+
if name.endsWith(".jar") then
9393
new dotty.tools.io.Jar(File(name)).toList.collect {
9494
case e if e.getName.endsWith(".tasty") =>
9595
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
9696
}
9797
else if (!name.endsWith(".tasty"))
9898
("", name) :: Nil
99-
else if (Files.exists(path))
99+
else if Files.exists(path) then
100100
TastyFileUtil.getClassName(path) match {
101101
case Some(res) => res:: Nil
102102
case _ =>
103-
report.error(s"Could not load classname from $name.")
104-
("", name) :: Nil
103+
report.error(s"Could not load classname from: $name")
104+
Nil
105105
}
106106
else {
107-
report.error(s"File $name does not exist.")
108-
("", name) :: Nil
107+
report.error(s"File does not exist: $name")
108+
Nil
109109
}
110110
}.unzip
111111
val ctx1 = ctx0.fresh

0 commit comments

Comments
 (0)