mirror of https://github.com/sbt/sbt.git
fix: Fix qual lookup
**Problem** Nested macro that expands to map or mapN fails to find the qual because the trees end up being different between the record scan and actual replacement. **Solution** First try for equals normally, then compare the show strings.
This commit is contained in:
parent
2ea0aac1bb
commit
f3dd5dbd71
|
|
@ -266,7 +266,15 @@ trait Cont:
|
||||||
(name: String, tpe: Type[x], qual: Term, oldTree: Term) =>
|
(name: String, tpe: Type[x], qual: Term, oldTree: Term) =>
|
||||||
given Type[x] = tpe
|
given Type[x] = tpe
|
||||||
convert[x](name, qual) transform { (replacement: Term) =>
|
convert[x](name, qual) transform { (replacement: Term) =>
|
||||||
val idx = inputs.indexWhere(input => input.qual == qual)
|
val idxEq = inputs.indexWhere(input => input.qual == qual)
|
||||||
|
// use show to compare trees for Def.task comparison
|
||||||
|
val idx =
|
||||||
|
if idxEq < 0 then inputs.indexWhere(input => input.qual.show == qual.show)
|
||||||
|
else idxEq
|
||||||
|
if idx < 0 then
|
||||||
|
sys.error(
|
||||||
|
s"qual (${qual}) not found in ${inputs.map(_.qual)}"
|
||||||
|
)
|
||||||
applyTuple(p0, br.inputTupleTypeRepr, idx)
|
applyTuple(p0, br.inputTupleTypeRepr, idx)
|
||||||
}
|
}
|
||||||
val modifiedBody =
|
val modifiedBody =
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
lazy val a1 = settingKey[Boolean]("")
|
||||||
|
|
||||||
|
scalaVersion := "3.6.4"
|
||||||
|
a1 := true
|
||||||
|
|
||||||
|
Compile / sourceGenerators += {
|
||||||
|
val _ = a1.value
|
||||||
|
Def.task {
|
||||||
|
Seq.empty[File]
|
||||||
|
}.taskValue
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
> compile
|
||||||
Loading…
Reference in New Issue