Skip to content

Commit 7d7d754

Browse files
committed
Prioritize tasty in DirectoryClassPath
1 parent e63493c commit 7d7d754

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

compiler/src/dotty/tools/dotc/classpath/DirectoryClassPath.scala

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -278,19 +278,19 @@ case class DirectoryClassPath(dir: JFile) extends JFileDirectoryLookup[ClassFile
278278

279279
def findClassFile(className: String): Option[AbstractFile] = {
280280
val relativePath = FileUtils.dirPath(className)
281-
val classFile = new JFile(dir, relativePath + ".class")
282-
if (classFile.exists) {
283-
Some(classFile.toPath.toPlainFile)
284-
}
285-
else {
286-
val tastyFile = new JFile(dir, relativePath + ".tasty")
287-
if tastyFile.exists then Some(tastyFile.toPath.toPlainFile)
281+
val tastyFile = new JFile(dir, relativePath + ".tasty")
282+
if tastyFile.exists then Some(tastyFile.toPath.toPlainFile)
283+
else
284+
val classFile = new JFile(dir, relativePath + ".class")
285+
if classFile.exists then Some(classFile.toPath.toPlainFile)
288286
else None
289-
}
290287
}
291288

292289
protected def createFileEntry(file: AbstractFile): ClassFileEntryImpl = ClassFileEntryImpl(file)
293-
protected def isMatchingFile(f: JFile): Boolean = f.isClass || f.isTasty
290+
protected def isMatchingFile(f: JFile): Boolean =
291+
def isClassWithNoTasty =
292+
f.isClass && !Files.exists(f.toPath.resolveSibling(f.getName.stripSuffix(".class").stripSuffix("$") + ".tasty"))
293+
f.isTasty || isClassWithNoTasty
294294

295295
private[dotty] def classes(inPackage: PackageName): Seq[ClassFileEntry] = files(inPackage)
296296
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
List(/tastyPaths/I8163.class)
1+
List(/tastyPaths/I8163.tasty)
22
`reflect.SourceFile.current` cannot be called within the TASTy ispector

0 commit comments

Comments
 (0)