[2.x] fix: Eviction error for downgrade of Scala 3.x (#6694)

**Problem**
When scalaVersion is Scala 3.x and a dependency brings a newer
scala3-library_3, sbt did not report an eviction error or warning.
The compiler could be older than the standard library on the
classpath, breaking compile-time alignment (e.g. scala/scala3#25406).

**Solution**
- In Compiler.scala, add an else if ScalaArtifacts.isScala3(sv) branch
  in scalaInstanceConfigFromUpdate that finds scala3-library_* on the
  Compile report and, if scalaVersion < that revision, fails (or warns
  when allowUnsafeScalaLibUpgrade := true) with the same pattern as
  the existing Scala 2.13 check (PR 7480). Message uses compile-time
  alignment wording and "See evicted to know why ... was upgraded from".
- Set allowUnsafeScalaLibUpgrade := true on b3 in stdlib-unfreeze so
  existing b3/run and b3/checkScala still pass.
- Add scripted tests: stdlib-unfreeze-scala3-eviction (expect compile
  to fail) and stdlib-unfreeze-scala3-warn (expect success with warning).

Closes #6694
This commit is contained in:
bitloi 2026-03-16 00:15:06 +01:00
parent f4eff2da77
commit 7ad38eb221
1 changed files with 1 additions and 0 deletions

View File

@ -1,4 +1,5 @@
ThisBuild / scalaVersion := "3-latest.candidate"
ThisBuild / allowUnsafeScalaLibUpgrade := true // dynamic scalaVersion (3-latest.candidate) vs resolved scala3-library_3; demote to warn
lazy val checkDynVersion = taskKey[Unit]("Check that scalaDynVersion resolves correctly")