From 41b7b9eef0dddd3ce75724d041a77e9adb51812f Mon Sep 17 00:00:00 2001 From: ckipp01 Date: Sat, 28 Nov 2020 13:33:20 +0100 Subject: [PATCH] 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. --- mdoc/src/main/scala/mdoc/internal/cli/Context.scala | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mdoc/src/main/scala/mdoc/internal/cli/Context.scala b/mdoc/src/main/scala/mdoc/internal/cli/Context.scala index 7010d28d5..9331ca167 100644 --- a/mdoc/src/main/scala/mdoc/internal/cli/Context.scala +++ b/mdoc/src/main/scala/mdoc/internal/cli/Context.scala @@ -16,13 +16,15 @@ case class Context( settings: Settings, reporter: Reporter, compiler: MarkdownCompiler, - compilers: mutable.Map[Set[Dependency], MarkdownCompiler] = mutable.Map.empty + compilers: mutable.Map[(Set[Dependency], List[String]), MarkdownCompiler] = mutable.Map.empty ) { - def compiler(instrumented: Instrumented) = + def compiler(instrumented: Instrumented) = { + val scalacOptions = instrumented.scalacOptionImports.map(_.value) compilers.getOrElseUpdate( - instrumented.dependencies, + (instrumented.dependencies, scalacOptions), Dependencies.newCompiler(settings, instrumented) ) + } } object Context {