From bd7bf73de5611aadd2ba727e54150b5e48130133 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sun, 16 Mar 2025 14:58:23 -0400 Subject: [PATCH] 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. --- main/src/main/scala/sbt/Defaults.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 0b54ba2e5..dbbbe84b1 100644 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -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)