Skip to content

Commit f2937db

Browse files
committed
Only allow jar and tasty as input for -from-tasty
1 parent 06d988a commit f2937db

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 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") && !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
92+
if !Files.exists(path) then
9593
report.error(s"File does not exist: $name")
9694
Nil
9795
else if name.endsWith(".jar") then
9896
new dotty.tools.io.Jar(File(name)).toList.collect {
9997
case e if e.getName.endsWith(".tasty") =>
10098
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
10199
}
102-
else
103-
assert(name.endsWith(".tasty"))
100+
else if name.endsWith(".tasty") then
104101
TastyFileUtil.getClassName(path) match
105102
case Some(res) => res :: Nil
106103
case _ =>
107104
report.error(s"Could not load classname from: $name")
108105
Nil
106+
else
107+
report.error(s"File extension is not `tasty` or `jar`: $name")
108+
Nil
109109
}.unzip
110110
val ctx1 = ctx0.fresh
111111
val classPaths1 = classPaths.distinct.filter(_ != "")

0 commit comments

Comments
 (0)