Skip to content

Commit 4639a10

Browse files
authored
Merge pull request #2569 from dotty-staging/hasTasty
Don't use empty files to indicate presence of tasty in class path.
2 parents 3f222ca + c2a935b commit 4639a10

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,16 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
205205
val dataAttr = new CustomAttr(nme.TASTYATTR.mangledString, binary)
206206
val store = if (mirrorC ne null) mirrorC else plainC
207207
store.visitAttribute(dataAttr)
208-
val outTastyFile = getFileForClassfile(outF, store.name, ".tasty")
209208
if (ctx.settings.emitTasty.value) {
209+
val outTastyFile = getFileForClassfile(outF, store.name, ".tasty")
210210
val outstream = new DataOutputStream(outTastyFile.bufferedOutput)
211211

212212
try outstream.write(binary)
213213
finally outstream.close()
214-
} else if (!outTastyFile.isVirtual) {
214+
} else {
215215
// Create an empty file to signal that a tasty section exist in the corresponding .class
216216
// This is much cheaper and simpler to check than doing classfile parsing
217-
outTastyFile.create()
217+
getFileForClassfile(outF, store.name, ".hasTasty")
218218
}
219219
}
220220

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,13 @@ class InteractiveDriver(settings: List[String]) extends Driver {
8585
binFile.name.stripSuffix(".class")
8686
else
8787
null
88+
// Presence of a file with one of these suffixes indicates that the
89+
// corresponding class has been pickled with TASTY.
90+
val tastySuffixes = List(".hasTasty", ".tasty")
8891
prefix != null && {
89-
val tastyFile = prefix + ".tasty"
9092
binFile match {
9193
case pf: PlainFile =>
92-
val tastyPath = pf.givenPath.parent / tastyFile
93-
tastyPath.exists
94+
tastySuffixes.map(suffix => pf.givenPath.parent / (prefix + suffix)).exists(_.exists)
9495
case _ =>
9596
sys.error(s"Unhandled file type: $binFile [getClass = ${binFile.getClass}]")
9697
}

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ object Build {
880880

881881

882882
sbtPlugin := true,
883-
version := "0.1.0",
883+
version := "0.1.1",
884884
ScriptedPlugin.scriptedSettings,
885885
ScriptedPlugin.sbtTestDirectory := baseDirectory.value / "sbt-test",
886886
ScriptedPlugin.scriptedBufferLog := false,

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,27 +79,27 @@ object DottyPlugin extends AutoPlugin {
7979
}
8080
}
8181

82-
/** Patches the IncOptions so that .tasty files are pruned as needed.
82+
/** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed.
8383
*
8484
* This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs
8585
* to do the exact same thing but for classfiles.
8686
*
8787
* This complicated logic patches the ClassfileManager factory of the given
88-
* IncOptions with one that is aware of .tasty files emitted by the Dotty
88+
* IncOptions with one that is aware of .tasty and .hasTasty files emitted by the Dotty
8989
* compiler. This makes sure that, when a .class file must be deleted, the
90-
* corresponding .tasty file is also deleted.
90+
* corresponding .tasty or .hasTasty file is also deleted.
9191
*/
9292
def dottyPatchIncOptions(incOptions: IncOptions): IncOptions = {
9393
val inheritedNewClassfileManager = incOptions.newClassfileManager
9494
val newClassfileManager = () => new ClassfileManager {
9595
private[this] val inherited = inheritedNewClassfileManager()
9696

9797
def delete(classes: Iterable[File]): Unit = {
98+
val tastySuffixes = List(".tasty", ".hasTasty")
9899
inherited.delete(classes flatMap { classFile =>
99100
val dottyFiles = if (classFile.getPath endsWith ".class") {
100-
val f = new File(classFile.getAbsolutePath.stripSuffix(".class") + ".tasty")
101-
if (f.exists) List(f)
102-
else Nil
101+
val prefix = classFile.getAbsolutePath.stripSuffix(".class")
102+
tastySuffixes.map(suffix => new File(prefix + suffix)).filter(_.exists)
103103
} else Nil
104104
classFile :: dottyFiles
105105
})

0 commit comments

Comments
 (0)