Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix classpath options #2269

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Fix classpath options #2269

merged 2 commits into from
Feb 13, 2024

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Feb 12, 2024

Fix #2268

We should cache the ScalaInstance to reuse classloaders as much as possible but we should take into account the ClasspathOptions of a project when we create the ScalaCompiler.

Tested on Dotty: compilation ✔️ auto-completion ✔️

@@ -50,19 +50,21 @@ final class CompilerCache(
logger: Logger
) {

private val scalaCompilerCache = new ConcurrentHashMap[ScalaInstance, ScalaCompiler]()

private val scalaInstanceCache = new ConcurrentHashMap[ScalaInstance, ScalaInstance]()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cache the ScalaInstance instead of the ScalaCompiler because two projects can have the same ScalaInstance but different ClasspathOptions.

@adpi2 adpi2 requested a review from tgodzik February 12, 2024 14:18
@adpi2 adpi2 mentioned this pull request Feb 12, 2024
@adpi2 adpi2 requested a review from rochala February 13, 2024 15:36
javacBin: Option[AbsolutePath],
javacOptions: List[String]
): Compilers = {
val scalaCompiler = scalaCompilerCache.computeIfAbsent(
val scalaInstanceFromCache = scalaInstanceCache.computeIfAbsent(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this cache any more, we can pass Scala instance directly

Copy link
Member Author

@adpi2 adpi2 Feb 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we really need it. It deduplicates ScalaInstance that are equal but not reference equal. The goal is to avoid using the class loaders from new ScalaInstance that are equal to old ones.

@adpi2 adpi2 merged commit d96ba1a into scalacenter:main Feb 13, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bloop can't compile Dotty
2 participants