Skip to content

Commit dda6bac

Browse files
committed
Hide old Tuple.toList and implement as extension
This should in theory be backwards TASTy compatible. Fixes scala#12721
1 parent 0cdc242 commit dda6bac

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

library/src/scala/Tuple.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ sealed trait Tuple extends Product {
1111
inline def toArray: Array[Object] =
1212
runtime.Tuples.toArray(this)
1313

14-
/** Create a copy this tuple as a List */
15-
inline def toList[This >: this.type <: Tuple]: List[Union[This]] =
16-
this.productIterator.toList.asInstanceOf[List[Union[This]]]
14+
private[scala] inline def toList: List[Union[this.type]] =
15+
this.productIterator.toList.asInstanceOf[List[Union[this.type]]]
1716

1817
/** Create a copy this tuple as an IArray */
1918
inline def toIArray: IArray[Object] =
@@ -231,6 +230,11 @@ object Tuple {
231230

232231
def fromProductTyped[P <: Product](p: P)(using m: scala.deriving.Mirror.ProductOf[P]): m.MirroredElemTypes =
233232
runtime.Tuples.fromProduct(p).asInstanceOf[m.MirroredElemTypes]
233+
234+
/** Create a copy this tuple as a List */
235+
extension [This <: Tuple](inline tuple: This)
236+
inline def toList: List[Union[This]] =
237+
tuple.productIterator.toList.asInstanceOf[List[Union[This]]]
234238
}
235239

236240
/** A tuple of 0 elements */

0 commit comments

Comments
 (0)