diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala index e916329c2101..36a72abe911a 100644 --- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala +++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala @@ -205,16 +205,16 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter val dataAttr = new CustomAttr(nme.TASTYATTR.mangledString, binary) val store = if (mirrorC ne null) mirrorC else plainC store.visitAttribute(dataAttr) - val outTastyFile = getFileForClassfile(outF, store.name, ".tasty") if (ctx.settings.emitTasty.value) { + val outTastyFile = getFileForClassfile(outF, store.name, ".tasty") val outstream = new DataOutputStream(outTastyFile.bufferedOutput) try outstream.write(binary) finally outstream.close() - } else if (!outTastyFile.isVirtual) { + } else { // Create an empty file to signal that a tasty section exist in the corresponding .class // This is much cheaper and simpler to check than doing classfile parsing - outTastyFile.create() + getFileForClassfile(outF, store.name, ".hasTasty") } } diff --git a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala index 4fd24637a4b2..d47f165c93a7 100644 --- a/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala +++ b/compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala @@ -85,12 +85,13 @@ class InteractiveDriver(settings: List[String]) extends Driver { binFile.name.stripSuffix(".class") else null + // Presence of a file with one of these suffixes indicates that the + // corresponding class has been pickled with TASTY. + val tastySuffixes = List(".hasTasty", ".tasty") prefix != null && { - val tastyFile = prefix + ".tasty" binFile match { case pf: PlainFile => - val tastyPath = pf.givenPath.parent / tastyFile - tastyPath.exists + tastySuffixes.map(suffix => pf.givenPath.parent / (prefix + suffix)).exists(_.exists) case _ => sys.error(s"Unhandled file type: $binFile [getClass = ${binFile.getClass}]") } diff --git a/project/Build.scala b/project/Build.scala index a94353f7b728..59a31a72e33d 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -880,7 +880,7 @@ object Build { sbtPlugin := true, - version := "0.1.0", + version := "0.1.1", ScriptedPlugin.scriptedSettings, ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test", ScriptedPlugin.scriptedBufferLog := false, diff --git a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala index b3ef759c7d9b..ed53d537c43e 100644 --- a/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala +++ b/sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala @@ -79,15 +79,15 @@ object DottyPlugin extends AutoPlugin { } } - /** Patches the IncOptions so that .tasty files are pruned as needed. + /** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed. * * This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs * to do the exact same thing but for classfiles. * * This complicated logic patches the ClassfileManager factory of the given - * IncOptions with one that is aware of .tasty files emitted by the Dotty + * IncOptions with one that is aware of .tasty and .hasTasty files emitted by the Dotty * compiler. This makes sure that, when a .class file must be deleted, the - * corresponding .tasty file is also deleted. + * corresponding .tasty or .hasTasty file is also deleted. */ def dottyPatchIncOptions(incOptions: IncOptions): IncOptions = { val inheritedNewClassfileManager = incOptions.newClassfileManager @@ -95,11 +95,11 @@ object DottyPlugin extends AutoPlugin { private[this] val inherited = inheritedNewClassfileManager() def delete(classes: Iterable[File]): Unit = { + val tastySuffixes = List(".tasty", ".hasTasty") inherited.delete(classes flatMap { classFile => val dottyFiles = if (classFile.getPath endsWith ".class") { - val f = new File(classFile.getAbsolutePath.stripSuffix(".class") + ".tasty") - if (f.exists) List(f) - else Nil + val prefix = classFile.getAbsolutePath.stripSuffix(".class") + tastySuffixes.map(suffix => new File(prefix + suffix)).filter(_.exists) } else Nil classFile :: dottyFiles })