[2.x] Fix ProjectMatrix invalid project ID with CrossVersion.full (#8484)

When using `ProjectMatrix` with `CrossVersion.full` and Scala 2 versions like `2.13.18`, the project ID incorrectly became `$1$2_13_18` instead of `foo2_13_18`.

**Root cause:** The Scala 3 compiler creates synthetic intermediate vals (e.g., `$1`) during macro expansion. The `enclosingTerm` function in the macros was stopping at these synthetic symbols instead of continuing up the symbol tree to find the actual val name.

**Fix:** Added `Flags.Synthetic` check to skip compiler-generated symbols in:
- `main-settings/src/main/scala/sbt/std/KeyMacro.scala`
- `lm-core/src/main/scala/sbt/librarymanagement/ConfigurationExtra.scala`

---------

Co-authored-by: byteforge38 <joseph.mc0803@gmail.com>
This commit is contained in:
byteforge 2026-01-11 16:17:26 -08:00 committed by GitHub
parent 813078695f
commit bd03184cf5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 6 deletions

View File

@ -105,9 +105,10 @@ private[sbt] object ConfigurationMacro:
@tailrec
def enclosingTerm(sym: Symbol): Symbol =
sym match
case sym if sym.flags.is(Flags.Macro) => enclosingTerm(sym.owner)
case sym if !sym.isTerm => enclosingTerm(sym.owner)
case _ => sym
case sym if sym.flags.is(Flags.Macro) => enclosingTerm(sym.owner)
case sym if sym.flags.is(Flags.Synthetic) => enclosingTerm(sym.owner)
case sym if !sym.isTerm => enclosingTerm(sym.owner)
case _ => sym
val term = enclosingTerm(Symbol.spliceOwner)
if !term.isValDef then
report.error(

View File

@ -72,9 +72,10 @@ private[sbt] object KeyMacro:
@tailrec
def enclosingTerm0(sym: Symbol): Symbol =
sym match
case sym if sym.flags.is(Flags.Macro) => enclosingTerm0(sym.owner)
case sym if !sym.isTerm => enclosingTerm0(sym.owner)
case _ => sym
case sym if sym.flags.is(Flags.Macro) => enclosingTerm0(sym.owner)
case sym if sym.flags.is(Flags.Synthetic) => enclosingTerm0(sym.owner)
case sym if !sym.isTerm => enclosingTerm0(sym.owner)
case _ => sym
enclosingTerm0(Symbol.spliceOwner)
private def enclosingClass(using Quotes) =