Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 13 additions & 5 deletions compiler/src/dotty/tools/dotc/Driver.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import core.Comments.{ContextDoc, ContextDocstrings}
import core.Contexts.{Context, ContextBase}
import core.{MacroClassLoader, Mode, TypeError}
import dotty.tools.dotc.ast.Positioned
import dotty.tools.io.File
import reporting._

import scala.util.control.NonFatal
Expand Down Expand Up @@ -70,19 +71,26 @@ class Driver {
protected def fromTastySetup(fileNames0: List[String], ctx0: Context): (List[String], Context) = {
if (ctx0.settings.fromTasty.value(ctx0)) {
// Resolve classpath and class names of tasty files
val (classPaths, classNames) = fileNames0.map { name =>
val (classPaths, classNames) = fileNames0.flatMap { name =>
val path = Paths.get(name)
if (!name.endsWith(".tasty")) ("", name)
if (name.endsWith(".jar")) {
new dotty.tools.io.Jar(File(name)).iterator.collect {
case e if e.getName.endsWith(".tasty") =>
(name, e.getName.stripSuffix(".tasty").replace("/", "."))
}.toList
}
else if (!name.endsWith(".tasty"))
("", name) :: Nil
else if (Files.exists(path)) {
TastyFileUtil.getClassName(path) match {
case Some(res) => res
case Some(res) => res:: Nil
case _ =>
ctx0.error(s"Could not load classname from $name.")
("", name)
("", name) :: Nil
}
} else {
ctx0.error(s"File $name does not exist.")
("", name)
("", name) :: Nil
}
}.unzip
val ctx1 = ctx0.fresh
Expand Down
5 changes: 5 additions & 0 deletions project/scripts/cmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ clear_out "$OUT"
"$SBT" ";dotc $SOURCE -d $OUT ;dotc -from-tasty -classpath $OUT -d $OUT1 $MAIN ;dotr -classpath $OUT1 $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"

echo "testing sbt dotc -from-tasty from a jar and dotr -classpath"
clear_out "$OUT"
"$SBT" ";dotc -d $OUT/out.jar $SOURCE ;dotc -from-tasty -d $OUT1 $OUT/out.jar ;dotr -classpath $OUT1 $MAIN" > "$tmp"
grep -qe "$EXPECTED_OUTPUT" "$tmp"

# check that `sbt dotc -decompile` runs
echo "testing sbt dotc -decompile"
"$SBT" ";dotc -decompile -color:never -classpath $OUT $MAIN" > "$tmp"
Expand Down