Skip to content

Commit 8994a84

Browse files
authored
Merge pull request #10010 from dotty-staging/avoid-double-errors
Improve error messages for -from-tasty compilation
2 parents bdf634c + 7c76651 commit 8994a84

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

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

Lines changed: 12 additions & 13 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"))
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))
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 _ =>
103-
report.error(s"Could not load classname from $name.")
104-
("", name) :: Nil
105-
}
106-
else {
107-
report.error(s"File $name does not exist.")
108-
("", name) :: Nil
109-
}
107+
report.error(s"Could not load classname from: $name")
108+
Nil
110109
}.unzip
111110
val ctx1 = ctx0.fresh
112111
val classPaths1 = classPaths.distinct.filter(_ != "")

0 commit comments

Comments
 (0)