Skip to content

Commit 528bb7e

Browse files
committed
Use a This parameter instead of this.type in Tuple.toList
1 parent 2e19304 commit 528bb7e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

library/src/scala/Tuple.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ sealed trait Tuple extends Product {
1313
runtime.Tuples.toArray(this)
1414

1515
/** Create a copy of this tuple as a List */
16-
inline def toList: List[Union[this.type]] =
16+
inline def toList[This >: this.type <: Tuple]: List[Union[This]] =
1717
this.productIterator.toList
18-
.asInstanceOf[List[Union[this.type]]]
18+
.asInstanceOf[List[Union[This]]]
1919

2020
/** Create a copy of this tuple as an IArray */
2121
inline def toIArray: IArray[Object] =

tests/pos/16654.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def toCsvFlat[A <: Product](a: A)(using m: scala.deriving.Mirror.ProductOf[A]) = {
2+
def flatTuple(any: Any): Tuple = any match
3+
case p: Product => p.productIterator.map(flatTuple).foldLeft(EmptyTuple: Tuple)(_ ++ _)
4+
case a => Tuple1(a)
5+
6+
val tuple = flatTuple(Tuple.fromProductTyped(a)).toList
7+
}

0 commit comments

Comments
 (0)