Support given in build.sbt

This commit is contained in:
xuwei-k 2026-07-05 09:44:24 +09:00 committed by kenji yoshida
parent c4e5e8654e
commit 8773c55965
4 changed files with 13 additions and 2 deletions

View File

@ -350,8 +350,8 @@ object BuildUtilLite:
/** Prepend `_root_` and import just the names. */
def importNamesRoot(names: Seq[String]): Seq[String] = importNames(names map rootedName)
/** Wildcard import `._` for all values. */
def importAll(values: Seq[String]): Seq[String] = importNames(values map { _ + "._" })
/** Wildcard import `.{*, given}` for all values. */
def importAll(values: Seq[String]): Seq[String] = importNames(values map { _ + ".{*, given}" })
def importAllRoot(values: Seq[String]): Seq[String] = importAll(values map rootedName)
def rootedName(s: String): String = if (s contains '.') "_root_." + s else s
end BuildUtilLite

View File

@ -0,0 +1,9 @@
given Foo[Int] = Foo(2)
given s: Foo[String] = Foo("a")
InputKey[Unit]("check") := {
assert(summon[Foo[Int]].value == 2)
assert(summon[Foo[String]].value == "a")
assert(s.value == "a")
}

View File

@ -0,0 +1 @@
case class Foo[A](value: A)

View File

@ -0,0 +1 @@
> check