Skip to content

Commit 64b7577

Browse files
committed
Only allow jar and tasty as input for -from-tasty
1 parent 7eac235 commit 64b7577

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,23 +90,23 @@ class Driver {
9090
// Resolve classpath and class names of tasty files
9191
val (classPaths, classNames) = fileNames0.flatMap { name =>
9292
val path = Paths.get(name)
93-
if !name.endsWith(".jar") && !name.endsWith(".tasty") then // is class name
94-
("", name) :: Nil // TODO remove this case. We cannot rely on an expected tasty file beeing loaded.
95-
else if !Files.exists(path) then
93+
if !Files.exists(path) then
9694
report.error(s"File does not exist: $name")
9795
Nil
9896
else if name.endsWith(".jar") then
9997
new dotty.tools.io.Jar(File(name)).toList.collect {
10098
case e if e.getName.endsWith(".tasty") && !fromTastyIgnoreList(e.getName) =>
10199
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
102100
}
103-
else
104-
assert(name.endsWith(".tasty"))
101+
else if name.endsWith(".tasty") then
105102
TastyFileUtil.getClassName(path) match
106103
case Some(res) => res :: Nil
107104
case _ =>
108105
report.error(s"Could not load classname from: $name")
109106
Nil
107+
else
108+
report.error(s"File extension is not `tasty` or `jar`: $name")
109+
Nil
110110
}.unzip
111111
val ctx1 = ctx0.fresh
112112
val classPaths1 = classPaths.distinct.filter(_ != "")

project/scripts/cmdTests

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ grep -qe "$EXPECTED_OUTPUT" "$tmp"
1010
# check that `sbt scalac` compiles and `sbt scala` runs it
1111
echo "testing sbt scalac -from-tasty and scala -classpath"
1212
clear_out "$OUT"
13-
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -from-tasty -classpath $OUT -d $OUT1 $MAIN ;scala -classpath $OUT1 $MAIN" > "$tmp"
13+
"$SBT" ";scalac $SOURCE -d $OUT ;scalac -from-tasty -d $OUT1 $OUT/$TASTY ;scala -classpath $OUT1 $MAIN" > "$tmp"
1414
grep -qe "$EXPECTED_OUTPUT" "$tmp"
1515

1616
echo "testing sbt scalac -from-tasty from a jar and scala -classpath"

0 commit comments

Comments
 (0)