Skip to content

Commit 97d2733

Browse files
KacperFKorbandwijnand
authored andcommitted
Review changes
1 parent 6280e71 commit 97d2733

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

library/src/scala/Tuple.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package scala
22
import annotation.showAsInfix
33
import compiletime._
44
import compiletime.ops.int._
5+
import scala.annotation.experimental
56

67
/** Tuple of arbitrary arity */
78
sealed trait Tuple extends Product {
@@ -57,8 +58,9 @@ sealed trait Tuple extends Product {
5758
/** Called on a tuple `(a1, ..., an)`, returns a new tuple `f(a1) ++ ... ++ f(an)`.
5859
* The result is typed as `Concat[F[A1], ...Concat[F[An], EmptyTuple]...])` if the tuple type is fully known.
5960
*/
60-
inline def flatMap[F[_] <: Tuple](f: [t] => t => F[t]): FlatMap[this.type, F] =
61-
runtime.Tuples.flatMap(this, f).asInstanceOf[FlatMap[this.type, F]]
61+
@experimental
62+
inline def flatMap[This >: this.type <: Tuple, F[_] <: Tuple](f: [t] => t => F[t]): FlatMap[This, F] =
63+
runtime.Tuples.flatMap(this, f).asInstanceOf[FlatMap[This, F]]
6264

6365
/** Given a tuple `(a1, ..., am)`, returns the tuple `(a1, ..., an)` consisting
6466
* of its first n elements.

project/MiMaFilters.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ object MiMaFilters {
1111
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SourceFileMethods.getJPath"),
1212
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SourceFileMethods.name"),
1313
exclude[DirectMissingMethodProblem]("scala.quoted.Quotes#reflectModule#SourceFileMethods.path"),
14+
15+
// New APIs marked @experimental in 3.1.0
16+
exclude[DirectMissingMethodProblem]("scala.runtime.Tuples.flatMap"),
1417
)
1518
}

tests/run/TupleFlatMap.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
@main def Test = {
22

33
println(
4-
Tuple().flatMap[[t] =>> (t, t)]([t] => (x: t) => (x, x))
4+
Tuple().flatMap[EmptyTuple, [t] =>> (t, t)]([t] => (x: t) => (x, x))
55
)
66

77
println(
8-
(1, 2, "x", "d").flatMap[[t] =>> (t, t)]([t] => (x: t) => (x, x))
8+
(1, 2, "x", "d").flatMap[(Int, Int, String, String), [t] =>> (t, t)]([t] => (x: t) => (x, x))
99
)
1010

1111
println(
12-
(1, "x").flatMap[[t] =>> EmptyTuple]([t] => (x: t) => Tuple())
12+
(1, "x").flatMap[(Int, String), [t] =>> EmptyTuple]([t] => (x: t) => Tuple())
1313
)
1414

1515
println(
16-
(1, "x").flatMap[[t] =>> (t, String)]([t] => (x: t) => (x, x.toString + "!"))
16+
(1, "x").flatMap[(Int, String), [t] =>> (t, String)]([t] => (x: t) => (x, x.toString + "!"))
1717
)
1818

19-
}
19+
}

0 commit comments

Comments
 (0)