Skip to content

Commit

Permalink
[prelude] fix Batch compilation warning (#795)
Browse files Browse the repository at this point in the history
The compiler started warning since the last update. The code is correct
so I'm suppressing the warning

```
[warn] -- [E029] Pattern Match Exhaustivity Warning: /Users/fwbrasil/workspace/kyo/kyo-prelude/shared/src/main/scala/kyo/Batch.scala:153:16
[warn] 153 |                case (_: Unit, items) =>
[warn]     |                ^
[warn]     |   match may not be exhaustive.
[warn]     |
[warn]     |   It would fail on pattern case: (_: internal.Source[Any, Any, S], _)
[warn]     |
[warn]     | longer explanation available when compiling with `-explain`
```
  • Loading branch information
fwbrasil authored Oct 30, 2024
1 parent 579a989 commit f0bfe52
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions kyo-prelude/shared/src/main/scala/kyo/Batch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,20 @@ object Batch:
case Expanded(_, source, _) => source
case _ => () // Used as a placeholder for items that aren't source calls
}
Kyo.foreach(pending.toSeq) {
case (_: Unit, items) =>
// No need for flushing
Chunk.from(items)
case (source: SourceAny, items: Seq[Expanded] @unchecked) =>
// Only request distinct items from the source
source(items.map(_.value).distinct).map { results =>
// Reassemble the results by iterating on the original collection
Kyo.foreach(items) { e =>
// Note how each value can have its own effects
capture(results(e.value).map(e.cont))
Kyo.foreach(pending.toSeq) { tuple =>
(tuple: @unchecked) match
case (_: Unit, items) =>
// No need for flushing
Chunk.from(items)
case (source: SourceAny, items: Seq[Expanded] @unchecked) =>
// Only request distinct items from the source
source(items.map(_.value).distinct).map { results =>
// Reassemble the results by iterating on the original collection
Kyo.foreach(items) { e =>
// Note how each value can have its own effects
capture(results(e.value).map(e.cont))
}
}
}
}
end flush

Expand Down

0 comments on commit f0bfe52

Please sign in to comment.