Skip to content

Commit 41b7b9e

Browse files
committed
Store compilers with dependencies *and* scalacOptions.
The main reason behind this change is that in Metals when a user adds or removes a `$scalac` magic import, it has no affect unless they close Metals and restart it. This leads to people assuming that the `$scalac` imports aren't working in Metals. This is because when we do a looking into the ctx compilers we are only taking into consideration the dependencies instead of the scalacOptions. This slight changes just makes the key `(Dependencies, scalacOptions)` instead of `Dependencies` so that when a user changes the `$scalac` import, it's taken into consideration when doing the lookup or providing a new compiler.
1 parent ee3cdcc commit 41b7b9e

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mdoc/src/main/scala/mdoc/internal/cli/Context.scala

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@ case class Context(
1616
settings: Settings,
1717
reporter: Reporter,
1818
compiler: MarkdownCompiler,
19-
compilers: mutable.Map[Set[Dependency], MarkdownCompiler] = mutable.Map.empty
19+
compilers: mutable.Map[(Set[Dependency], List[String]), MarkdownCompiler] = mutable.Map.empty
2020
) {
21-
def compiler(instrumented: Instrumented) =
21+
def compiler(instrumented: Instrumented) = {
22+
val scalacOptions = instrumented.scalacOptionImports.map(_.value)
2223
compilers.getOrElseUpdate(
23-
instrumented.dependencies,
24+
(instrumented.dependencies, scalacOptions),
2425
Dependencies.newCompiler(settings, instrumented)
2526
)
27+
}
2628
}
2729

2830
object Context {

0 commit comments

Comments
 (0)