Skip to content

Commit 0146eb3

Browse files
Document Concat covariance in 2nd parameter
1 parent 86e5ca2 commit 0146eb3

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

library/src/scala/Tuple.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ sealed trait Tuple extends Product:
3434
/** Return a new tuple by concatenating `this` tuple with `that` tuple.
3535
* This operation is O(this.size + that.size)
3636
*/
37+
// Contrarily to `this`, `that` does not need a type parameter
38+
// since `++` is covariant in its second argument.
3739
inline def ++ [This >: this.type <: Tuple](that: Tuple): This ++ that.type =
3840
runtime.Tuples.concat(this, that).asInstanceOf[Concat[This, that.type]]
3941

@@ -165,6 +167,7 @@ object Tuple:
165167
infix type :*[X <: Tuple, Y] = Append[X, Y]
166168

167169
/** Type of the concatenation of two tuples `X` and `Y` */
170+
// Can be covariant in `Y` since it never appears as a match type scrutinee.
168171
type Concat[X <: Tuple, +Y <: Tuple] <: Tuple = X match
169172
case EmptyTuple => Y
170173
case x *: xs => x *: Concat[xs, Y]

0 commit comments

Comments
 (0)