[2.x] Fix macro expand for HKT type arguments (#9377)

Def.setting and Def.task macro expansion looks for internal wrapper
call generated for .value.

It visits all function calls in the macro. If the block contains
functions call whose type parameter is HKT, macro expansion crashed.

Macro expansion tries to match IO against '[a], and failed with MatchError.

This commit adds wildcard pattern, and leave unmatched type arguments unchanged.
This commit is contained in:
Rikito Taniguchi 2026-06-25 10:22:11 +09:00 committed by GitHub
parent 7575c5a1be
commit 10f98e6c01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 0 deletions

View File

@ -64,6 +64,8 @@ trait Convert[C <: Quotes & Singleton] extends ContextUtil[C]:
report.errorAndAbort(message, position)
case _ =>
super.transformTerm(tree)(owner)
case _ =>
super.transformTerm(tree)(owner)
case _ =>
super.transformTerm(tree)(owner)
end appTransformer

View File

@ -29,6 +29,30 @@ object UseTask:
}
end UseTask
// https://github.com/sbt/sbt/issues/9375
object UseHktTypeArgument:
final class IO[A]
object Builder:
def apply[F[_]](value: String): String = value
val settingWithHktTypeArgument: Def.Initialize[String] = Def.setting {
Builder[IO]("setting")
}
val taskWithHktTypeArgument: Def.Initialize[Task[String]] = Def.task {
Builder[IO]("task")
}
val name = Def.settingKey[String]("name")
val key = Def.taskKey[String]("key")
val settings = Seq(
key := Def.uncached {
Builder[IO](name.value)
}
)
end UseHktTypeArgument
object Assign {
import java.io.File