# Scala 2.13.12 in-source sbt compiler bridge clarifications

**URL:** <https://contributors.scala-lang.org/t/scala-2-13-12-in-source-sbt-compiler-bridge-clarifications/6289>\
**Category:** Tooling\
**Created:** [August 24, 2023, 2:20pm UTC](https://contributors.scala-lang.org/t/scala-2-13-12-in-source-sbt-compiler-bridge-clarifications/6289 "2023-08-24T14:20:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vasilmkd](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/vasilmkd/32/2775_2.png) [@vasilmkd](https://contributors.scala-lang.org/u/vasilmkd)\
**Post date:** [August 24, 2023, 2:20pm UTC](https://contributors.scala-lang.org/t/scala-2-13-12-in-source-sbt-compiler-bridge-clarifications/6289/1 "2023-08-24T14:20:28Z")

</div>

The sbt compiler bridge sources have been copied from the Zinc repository to the Scala 2.13 compiler repository and the precompiled bridge will be released alongside the compiler from now on.

> <https://github.com/scala/scala/pull/10472>
>
> Previous attempt: https://github.com/scala/scala/pull/8531. I think it was just …closed because there was no strong reason to do it.
> 
> This time there is a good reason: to support "quick fixes" / code actions that the Scala 2.13.12 compiler delivers with warnings and errors, the bridge needs to be changed. This cannot be done in a source-compatible manner, i.e., the bridge sources need to be different for 2.13.11 and 2.13.12. Instead of having multiple versions of the bridge sources for 2.13 compiler versions, releasing the bridge as binary with every Scala release might be easier. Details at https://github.com/sbt/zinc/discussions/1214.
> 
> This PR includes the git history of the compiler bridge. Documentation how it was done:
> - https://github.com/lrytz/scala/commit/80e8df93f854e8bb5ba7971c2af4d85671ccda08
> - https://github.com/lrytz/scala/commit/b8cebccd3f93fd90ab1f8e653dd98d3e63c3b496
> 
> The bridge tests from the zinc repo were also migrated (without history).
> 
> Advantages of in-sourcing the bridge
> - No more "'compiler-interface' not yet compiled..." for users
> - We can more easily improve / clean up the bridge sources without worrying about older compilers
> - Alignment with what Scala 3 does
> 
> A new \`scala2-sbt-bridge\` artifact will be published with every Scala release.
> 
> New sbt releases can use the binary bridge instead of compiling it from source.
> 
> The binary bridge can be used with existing sbt versions by setting the \`scalaCompilerBridgeBinaryJar\`. Here's how I tried it - probably there are more elegant solutions:
> 
> \`\`\`scala
> scalaCompilerBridgeBinaryJar := {
> val b = (nix / Compile / dependencyClasspath).value.filter(\_.data.getName == "scala2-sbt-bridge.jar").headOption
> b.map(\_.data)
> }
> val nix = project.in(file("nix")).settings(
> autoScalaLibrary := false,
> libraryDependencies += "org.scala-lang" % "scala2-sbt-bridge" % scalaVersion.value
> )
> \`\`\`
> 
> ~I haven't managed yet to make an end-to-end test for quick fixes with metals in VS code, WIP / discussion here https://github.com/sbt/zinc/discussions/1214#discussioncomment-6468903~

I would like to use this discussion to clarify some things for tooling developers.

1. Scala 2.13.12 onwards will distribute a precompiled sbt compiler bridge binary that will be resolvable from Maven Central. This behavior matches Scala 3, which has been distributing a compiler bridge binary since the first 3.0 release. Tools that invoke the compiler will no longer have to compile the bridge from sources in order to use the compiler. Are these statements correct?

2. The Scala Plugin for IntelliJ IDEA currently packages the sbt compiler bridge sources (originating from the Zinc repository) inside the plugin itself, in order to be able to compile the bridge and invoke the compiler. Today, I was able to build the Scala Plugin using Scala 2.13.12-bin-49d5507, from inside IDEA itself. This means that the Zinc compiler bridge sources were successfully compiled for Scala 2.13.12. Is this a lucky coincidence, and should we expect this to no longer be possible in the future, i.e. there will be a point in the future where the sbt bridge sources in the compiler will diverge from the ones in Zinc? Even if the bridge from the Zinc repository can be successfully compiled in the future, will it have fewer features, for example less or no support for quick fixes? Should we switch to dynamically resolving the precompiled bridge which is distributed with the compiler? In any case, we’re currently happy that our users will be able to use Scala 2.13.12 out of the box, without having to wait for a new patch release of the Scala Plugin.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![lrytz](https://contributors.scala-lang.org/user_avatar/contributors.scala-lang.org/lrytz/32/1653_2.png) [@lrytz](https://contributors.scala-lang.org/u/lrytz)\
**Post date:** [August 24, 2023, 2:57pm UTC](https://contributors.scala-lang.org/t/scala-2-13-12-in-source-sbt-compiler-bridge-clarifications/6289/2 "2023-08-24T14:57:02Z")

</div>

> [@vasilmkd](#):
>
> Tools that invoke the compiler will no longer have to compile the bridge from sources in order to use the compiler. Are these statements correct?

Yes. But all currently available sbt (and other build tool) releases don’t know about this change yet, so they will continue to compile the bridge from source also for 2.13.12+.

> [@vasilmkd](#):
>
> Is this a lucky coincidence, and should we expect this to no longer be possible in the future

We will continue to remain source compatible with the bridge source as they currently are in zinc, otherwise existing zinc releases would not work with new Scala releases.

> [@vasilmkd](#):
>
> will it have fewer features, for example less or no support for quick fixes?

Yes, that is the case. Support for quick fixes is only there when using the binary bridge.
