Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/src/scala/Tuple.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ object Tuple {
* ```
* @syntax markdown
*/
type Filter[Tup <: Tuple, P[_] <: Boolean] <: Tuple = Tup match {
type Filter[Tup <: Tuple, P[_ <: Union[Tup]] <: Boolean] <: Tuple = Tup match {
case EmptyTuple => EmptyTuple
case h *: t => P[h] match {
case true => h *: Filter[t, P]
Expand Down
12 changes: 12 additions & 0 deletions tests/neg/tuple-filter-compat.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

type OldFilter[Tup <: Tuple, P[_] <: Boolean] = Nothing
type NewFilter[Tup <: Tuple, P[_ <: Tuple.Union[Tup]] <: Boolean] = Nothing

trait A:
type X >: OldFilter <: OldFilter

trait B1 extends A:
type X = OldFilter // ok

trait B2 extends A:
type X = NewFilter // error: breaking change
6 changes: 6 additions & 0 deletions tests/pos/tuple-filter.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import scala.compiletime.ops.int.<

type P[x] <: Boolean = x match {
case 3 => false
case _ => true
}

type RejectAll[x] = false

type Pos[X <: Int] = 0 < X

def Test =
summon[Tuple.Filter[(1, 2, 3, 4), P] =:= (1, 2, 4)]
summon[Tuple.Filter[(1, 2, 3, 4), RejectAll] =:= EmptyTuple]
summon[Tuple.Filter[EmptyTuple, P] =:= EmptyTuple]
summon[Tuple.Filter[(1, -2, 3, -4), Pos] =:= (1, 3)]
Loading