-
Notifications
You must be signed in to change notification settings - Fork 203
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
Fix classpath options #2269
Conversation
@@ -50,19 +50,21 @@ final class CompilerCache( | |||
logger: Logger | |||
) { | |||
|
|||
private val scalaCompilerCache = new ConcurrentHashMap[ScalaInstance, ScalaCompiler]() | |||
|
|||
private val scalaInstanceCache = new ConcurrentHashMap[ScalaInstance, ScalaInstance]() |
There was a problem hiding this comment.
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
.
javacBin: Option[AbsolutePath], | ||
javacOptions: List[String] | ||
): Compilers = { | ||
val scalaCompiler = scalaCompilerCache.computeIfAbsent( | ||
val scalaInstanceFromCache = scalaInstanceCache.computeIfAbsent( |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Fix #2268
We should cache the
ScalaInstance
to reuse classloaders as much as possible but we should take into account theClasspathOptions
of a project when we create theScalaCompiler
.Tested on Dotty: compilation ✔️ auto-completion ✔️