Skip to content

Commit 35cbf65

Browse files
committed
InteractiveDriver: Always look for hasTasty files
When we changed the tasty marker to be either .hasTasty or .tasty files, we missed a few places where we need to look for either of them.
1 parent 8ddfcaf commit 35cbf65

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

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

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ class InteractiveDriver(settings: List[String]) extends Driver {
6969
}
7070
}
7171

72+
// Presence of a file with one of these suffixes indicates that the
73+
// corresponding class has been pickled with TASTY.
74+
private val tastySuffixes = List(".hasTasty", ".tasty")
75+
7276
private def classNames(cp: ClassPath, packageName: String): List[String] = {
7377
def className(classSegments: List[String]) =
7478
classSegments.mkString(".").stripSuffix(".class")
@@ -85,9 +89,6 @@ class InteractiveDriver(settings: List[String]) extends Driver {
8589
binFile.name.stripSuffix(".class")
8690
else
8791
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")
9192
prefix != null && {
9293
binFile match {
9394
case pf: PlainFile =>
@@ -123,8 +124,12 @@ class InteractiveDriver(settings: List[String]) extends Driver {
123124
.stream
124125
.toArray(new IntFunction[Array[ZipEntry]] { def apply(size: Int) = new Array(size) })
125126
.toSeq
126-
entries.filter(_.getName.endsWith(".tasty"))
127-
.map(_.getName.replace("/", ".").stripSuffix(".tasty"))
127+
for {
128+
entry <- entries
129+
name = entry.getName
130+
tastySuffix <- tastySuffixes
131+
if name.endsWith(tastySuffix)
132+
} yield name.replace("/", ".").stripSuffix(tastySuffix)
128133
}
129134

130135
// FIXME: classfiles in directories may change at any point, so we retraverse
@@ -136,8 +141,14 @@ class InteractiveDriver(settings: List[String]) extends Driver {
136141
val root = dirCp.dir.toPath
137142
Files.walkFileTree(root, new SimpleFileVisitor[Path] {
138143
override def visitFile(path: Path, attrs: BasicFileAttributes) = {
139-
if (!attrs.isDirectory && path.getFileName.toString.endsWith(".tasty")) {
140-
names += root.relativize(path).toString.replace("/", ".").stripSuffix(".tasty")
144+
if (!attrs.isDirectory) {
145+
val name = path.getFileName.toString
146+
for {
147+
tastySuffix <- tastySuffixes
148+
if name.endsWith(tastySuffix)
149+
} {
150+
names += root.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix)
151+
}
141152
}
142153
FileVisitResult.CONTINUE
143154
}

0 commit comments

Comments
 (0)