fix: Fix SIP-51 message

**Problem**
The error message uses name, which may not match the actual project id
that the user can type into the shell.

**Solution**
Use displayBuildRelative to calculate the proper subproject id.
This commit is contained in:
Eugene Yokota 2025-03-16 14:58:23 -04:00
parent 9c08aea5fc
commit bd7bf73de5
1 changed files with 3 additions and 3 deletions

View File

@ -1213,7 +1213,7 @@ object Defaults extends BuildCommon {
for (lib <- scalaDeps.take(1)) {
val libVer = lib.module.revision
val libName = lib.module.name
val n = name.value
val proj = Def.displayBuildRelative(thisProjectRef.value.build, thisProjectRef.value)
if (VersionNumber(sv).matchesSemVer(SemanticSelector(s"<$libVer"))) {
val err = !allowUnsafeScalaLibUpgrade.value
val fix =
@ -1227,13 +1227,13 @@ object Defaults extends BuildCommon {
|Compilation (macro expansion) or using the Scala REPL in sbt may fail with a LinkageError.""".stripMargin
val msg =
s"""Expected `$n/scalaVersion` to be $libVer or later, but found $sv.
s"""Expected `$proj scalaVersion` to be $libVer or later, but found $sv.
|To support backwards-only binary compatibility (SIP-51), the Scala 2.13 compiler
|should not be older than $libName on the dependency classpath.
|
|$fix
|
|See `$n/evicted` to know why $libName $libVer is getting pulled in.
|See `$proj evicted` to know why $libName $libVer is getting pulled in.
|""".stripMargin
if (err) sys.error(msg)
else s.log.warn(msg)