Skip to content

[DRAFT] Run "2.13.y" scripted projects on scala2-sbt-bridge - #11

Closed
retronym wants to merge 7 commits into
developfrom
claude/1807-bridge-test-on9ml0
Closed

retronym wants to merge 7 commits into
developfrom
claude/1807-bridge-test-on9ml0

Conversation

@retronym

@retronym retronym commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Fixes sbt#1836

Problem

Scripted build.json files name a Scala version by label (2.12.x, 2.13.y, ...) rather than by patch version, so tests survive Scala upgrades. 46d2131 ("Incorporate Scala 3 binary bridge to scripted") introduced the y and 3.x labels so that scripted can also run against the bridges that ship with the Scala compilers, which are what sbt uses in real builds:

Label Compiler Bridge
2.10.x ... 2.13.x scala210 ... scala213 zinc's own compiler-bridge sources
2.13.y scala213ForBridge scala2-sbt-bridge (ships with Scala 2.13)
3.x scala3ForBridge scala3-sbt-bridge (ships with Scala 3)

2.13.y has never selected scala2-sbt-bridge. Scripted looks a bridge up by Scala version and takes the first match. The compilerBridgeScala213Bin project used scala213 as its version, which is the same string as for the source bridge, so the source bridge always won. When 46d2131 landed, scala213 and scala213ForBridge were both 2.13.13. No scripted test uses 2.13.y, so nothing noticed.

I found this while backporting sbt#1807 to 1.12.x. Runs I took to be on the stock 2.13 bridge were really on zinc's patched bridge, so the bridge half of sbt#1807 looked unnecessary on 2.13.

A related gap: all projects in a scripted test share the compiler of the first project that runs a task, so a second scalaVersion in one build.json was silently ignored. No existing test mixes versions.

Changes

  • The label now selects the bridge. BridgeProviderTestkit keeps the bridges in a map by label, and IncHandler gets a provider holding only the selected bridge. The compiler cache and the copied bridge jar (target-bridge-<label>.jar) are keyed by label, so 2.13.x and 2.13.y stay separate even when both are built for the same Scala version. I checked this by setting both to 2.13.16.
  • New scripted command checkBridge <zinc|scala2-sbt-bridge|scala3-sbt-bridge> asserts which bridge compiled the test. It opens the bridge jar and looks at the package of CompilerBridge. general/bridge-{2.12.x,2.13.x,2.13.y,3.x} use it, one per label.
  • A test whose projects use different labels now fails on its first command, listing the projects and labels. Only that test fails, not the whole run.
  • compilerBridgeScala213Bin now compiles with scala213ForBridge, the version it already fetches scala2-sbt-bridge at, so the compiler and the bridge jar always come from the same release. Before, they agreed only because both versions happened to be 2.13.16.
  • scala213ForBridge goes from 2.13.16 to 2.13.18. That is the current Scala 2.13 release and the version zinc 1.12.x already uses (Run scripted tests on Scala 2.12, 2.13 and 3 sbt/zinc#1829). scala2-sbt-bridge is the bridge sbt and other build tools load for 2.13.13 and later, so 2.13.y should test the one users get today. The label fix above does not depend on the bump, and no released scala2-sbt-bridge reports name kinds, so the pending test below fails the same way on any of them (I ran it on 2.13.17 and 2.13.18).
  • contributing-docs/03_scripted_tests.md documents the labels, why 2.13.y exists, checkBridge, and the one-version-per-test rule.
  • New pending test source-dependencies/module-inheritance-extra-hash-213-bin runs the module-inheritance case on the stock bridge. It fails at the last checkRecompilations 0 D. Without name kinds, object B extends A counts as trait B inheriting A, so a private change in A reaches D. Once scala2-sbt-bridge reports NameKind (retronym/scala#135), the test passes and fails as "pending test passed", which is the cue to remove the pending file.

Testing

The new scripted tests run in CI. Two checks are not in CI, so I ran them as throwaway tests to confirm they fail when they should:

  • checkBridge scala2-sbt-bridge on a 2.13.x project: Expected bridge scala2-sbt-bridge (scala/tools/xsbt/CompilerBridge.class), found zinc.
  • A build.json with 2.13.x and 2.13.y: Projects in one scripted test share a compiler, so they must use one scalaVersion: a: 2.13.x, b: 2.13.y. The other tests in the run still pass.

@retronym retronym self-assigned this Oct 3, 2026
@retronym
retronym changed the base branch from upstream-develop to develop October 3, 2026 10:29
@retronym
retronym force-pushed the claude/1807-bridge-test-on9ml0 branch from 763402e to 8f89715 Compare October 3, 2026 10:31
@retronym retronym changed the title Run "2.13.y" scripted projects on scala2-sbt-bridge [DRAFT] Run "2.13.y" scripted projects on scala2-sbt-bridge Oct 4, 2026
expected,
sys.error(s"Unknown bridge '$expected', expected one of ${markers.keys.mkString(", ")}")
)
val zip = new java.util.zip.ZipFile(i.compilerBridge.toFile)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Use an import here

val scala3 = "3.9.0"
val scala3ForBridge = "3.9.0"
val scala213ForBridge = "2.13.16"
val scala213ForBridge = "2.13.18"

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

justify this change in the PR decription and commit message

),
)

private val bridgeLabels = List("2.10.x", "2.11.x", "2.12.x", "2.13.x", "2.13.y", "3.x")

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Extract constants for these rather than duplicating with above

Scripted picks a bridge by Scala version, and compilerBridgeScala213Bin
used scala213, the version of the compiler-bridge sources. So "2.13.y"
silently ran on zinc's own bridge. Use scala213ForBridge for it, and fail
fast if the two versions are ever equal.

Bump scala213ForBridge from 2.13.16 to 2.13.18, the latest 2.13 release
(as sbt#1829 also does). sbt compiles 2.13.12 and later with the
scala2-sbt-bridge of the project's own Scala version, so "2.13.y" should
test the newest stock bridge, which is what current sbt users get. It also
gives the two 2.13 bridges different versions, which version-based lookup
needs here; the next commit selects bridges by label, after which that is
no longer required.

Add module-inheritance-extra-hash-213-bin, pending: scala2-sbt-bridge does
not report name kinds yet (sbt#1807's bridge side), so `object B
extends A` still counts as trait B inheriting A on 2.13 and D recompiles.
A scripted project's scalaVersion ("2.13.x", "2.13.y", ...) now selects
its bridge directly, and the compiler cache and bridge jar are keyed by
that label. So "2.13.x" and "2.13.y" stay apart even when the bridge
sources and scala2-sbt-bridge are built for the same Scala version.

checkBridge asserts which bridge compiles a test, from the package of
CompilerBridge in the bridge jar: zinc's sources (xsbt),
scala2-sbt-bridge (scala.tools.xsbt) or scala3-sbt-bridge
(dotty.tools.xsbt). The general/bridge-* tests use it for each label.
Explain what 2.13.x, 2.13.y and 3.x select, and why the bridge is chosen by label.
All projects in a scripted test share the compiler of the first one that runs a task, so a second scalaVersion was silently ignored. No existing test mixes versions.
@retronym
retronym force-pushed the claude/1807-bridge-test-on9ml0 branch from 48fea0b to 17d9651 Compare October 5, 2026 00:17
@retronym

retronym commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

Superseded by sbt#1837

@retronym retronym closed this Oct 5, 2026
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.

1 participant