Skip to content

Improve error messages for -from-tasty compilation #10010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,23 @@ class Driver {
// Resolve classpath and class names of tasty files
val (classPaths, classNames) = fileNames0.flatMap { name =>
val path = Paths.get(name)
if (name.endsWith(".jar"))
if !name.endsWith(".jar") && !name.endsWith(".tasty") then // is class name
("", name) :: Nil // TODO remove this case. We cannot rely on an expected tasty file beeing loaded.
else if !Files.exists(path) then
report.error(s"File does not exist: $name")
Nil
else if name.endsWith(".jar") then
new dotty.tools.io.Jar(File(name)).toList.collect {
case e if e.getName.endsWith(".tasty") =>
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
}
else if (!name.endsWith(".tasty"))
("", name) :: Nil
else if (Files.exists(path))
TastyFileUtil.getClassName(path) match {
case Some(res) => res:: Nil
else
assert(name.endsWith(".tasty"))
TastyFileUtil.getClassName(path) match
case Some(res) => res :: Nil
case _ =>
report.error(s"Could not load classname from $name.")
("", name) :: Nil
}
else {
report.error(s"File $name does not exist.")
("", name) :: Nil
}
report.error(s"Could not load classname from: $name")
Nil
}.unzip
val ctx1 = ctx0.fresh
val classPaths1 = classPaths.distinct.filter(_ != "")
Expand Down