Skip to content

Commit aee8a9f

Browse files
Fix scala#15992: Map on Tuples must widen its keys.
1 parent 50d2a48 commit aee8a9f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

library/src/scala/Tuple.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ sealed trait Tuple extends Product {
5656
* If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
5757
* to be the cons type.
5858
*/
59-
inline def map[F[_]](f: [t] => t => F[t]): Map[this.type, F] =
60-
runtime.Tuples.map(this, f).asInstanceOf[Map[this.type, F]]
59+
inline def map[This >: this.type <: Tuple, F[_]](f: [t] => t => F[t]): Map[This, F] =
60+
runtime.Tuples.map(this, f).asInstanceOf[Map[This, F]]
6161

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

tests/pos/i15992.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def widen[T](x: T): T = x
2+
3+
def f[T <: Tuple](t: T): Unit =
4+
val tl: Tuple.Map[T, List] = widen(t).map([X] => (x: X) => List(x))

0 commit comments

Comments
 (0)