use require for some argument checks instead of assert (#15646)

- suggested by @avdv in #15565; thanks
This commit is contained in:
Stephen Compall 2022-11-22 10:13:59 -05:00 committed by GitHub
parent ba595c4ee7
commit 51c3865701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -546,7 +546,7 @@ object Queries {
selector: Fragment,
): Fragment =
fr"CASE" ++ {
assert(m.nonEmpty, "existing offsets must be non-empty")
require(m.nonEmpty, "existing offsets must be non-empty")
val when +: whens = m.iterator.map { case (k, v) =>
fr"WHEN ($selector = $k) THEN $v"
}.toVector
@ -600,7 +600,7 @@ object Queries {
size: Int,
groups: NonEmpty[Map[K, NonEmpty[Set[V]]]],
): NonEmpty[Map[K, NonEmpty[Vector[NonEmpty[Set[V]]]]]] = {
assert(size > 0, s"chunk size must be positive, not $size")
require(size > 0, s"chunk size must be positive, not $size")
groups.transform { (_, nesv) =>
nesv.grouped(size).collect { case NonEmpty(sv) => sv }.toVector match {
case NonEmpty(svs) => svs