From 7ad38eb22113c11195b4ccc4ec72f332bbe205f4 Mon Sep 17 00:00:00 2001 From: bitloi Date: Mon, 16 Mar 2026 00:15:06 +0100 Subject: [PATCH] [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 --- sbt-app/src/sbt-test/project/scala-dyn-version/build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/sbt-app/src/sbt-test/project/scala-dyn-version/build.sbt b/sbt-app/src/sbt-test/project/scala-dyn-version/build.sbt index cade63196..c734d84ae 100644 --- a/sbt-app/src/sbt-test/project/scala-dyn-version/build.sbt +++ b/sbt-app/src/sbt-test/project/scala-dyn-version/build.sbt @@ -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")