Simplify classpath code - #26712
Open
SolalPirelli wants to merge 4 commits into
Open
Conversation
SolalPirelli
commented
Aug 5, 2026
| * the Scala 2 library as it has one JAR containing the class files and one JAR containing the TASTy files. | ||
| * As classpath orders are not guaranteed to be deterministic we might end up having the TASTy in a later classpath entry. | ||
| */ | ||
| private def mergeClassesAndSources(entries: scala.collection.Seq[ClassRepresentation]): Seq[ClassRepresentation] = { |
SolalPirelli
commented
Aug 5, 2026
| } | ||
| entriesBuffer.toIndexedSeq | ||
| } | ||
| aggregates.flatMap(getEntries).filter(e => seenNames.add(e.name)) |
Contributor
Author
There was a problem hiding this comment.
this was overly convoluted
SolalPirelli
commented
Aug 5, 2026
| */ | ||
| package dotty.tools.dotc.classpath | ||
|
|
||
| import dotty.tools.io.{AbstractFile, ClassRepresentation, FileExtension} |
Contributor
Author
There was a problem hiding this comment.
changes in this file:
- add ClassPath, unmodified, from io (yes this file is already named ClassPath but it didn't contain ClassPath...)
- remove subclasses of ClassRepresentation that were unused
- including making
BinaryFileEntryconcrete and delete its subclasses since they all did the same thing and were never pattern-matched outside of now-dead code
- including making
SolalPirelli
commented
Aug 5, 2026
| protected def toAbstractFile(f: JFile): AbstractFile = f.toPath.toPlainFile | ||
| protected def isPackage(f: JFile): Boolean = f.isPackage | ||
|
|
||
| assert(dir.asInstanceOf[JFile | Null] != null, "Directory file in DirectoryFileLookup cannot be null") |
Contributor
Author
There was a problem hiding this comment.
this was testing the type system....
SolalPirelli
commented
Aug 5, 2026
| // Right now the compiler always asks for those at the root package anyway (inPackage == ""), | ||
| // and we have no way to query the file system for "entries without a dot in their name", | ||
| // so might as well cache them | ||
| private val allPackages = listFiles(dir).map(f => f.getFileName.toString) |
Contributor
Author
There was a problem hiding this comment.
moved up since it's now used by multiple methods
Member
|
Benchmarks started. Workflow run. |
Member
|
Benchmarks completed. Overview. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClassPathto theclasspathpackage where it should be (it was inio)PackageEntry(makes it harder to cache packages, since you need to create a PackageEntry just to test whether a string is in a collection)JrtClassPath(turns outFiles.existsinjrt://internally throws an exception and catches it...)Makes some benchmarks 1% faster, others are noise.
Have you relied on LLM-based tools in this contribution?
No
How was the solution tested?
Covered by existing tests (this is a refactoring)