From ea7eb13170a1759cbd99909e5035fb1d47ca07f9 Mon Sep 17 00:00:00 2001 From: Jamie Thompson Date: Thu, 11 Dec 2025 09:23:46 +0100 Subject: [PATCH] Ensure stability of IArray.tapEach previously in source it called `arr.toSeq.forEach`, relying on a potential flaky implicit conversion to scala.collection.immutable.ArraySeq. make the conversion explicit, so that it never uses Predef.genericWrapArray, which would copy when calling .toSeq --- library/src/scala/IArray.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/scala/IArray.scala b/library/src/scala/IArray.scala index 58e34373c6e9..bdef8b668592 100644 --- a/library/src/scala/IArray.scala +++ b/library/src/scala/IArray.scala @@ -306,7 +306,7 @@ object IArray: def stepper[S <: Stepper[?]](using StepperShape[T, S]): S = genericArrayOps(arr).stepper[S] def tails: Iterator[IArray[T]] = genericArrayOps(arr).tails def tapEach[U](f: (T) => U): IArray[T] = - arr.toSeq.foreach(f) + IArray.genericWrapArray(arr).foreach(f) // just to be sure it doesnt clone arr def transpose[U](implicit asArray: T => IArray[U]): IArray[IArray[U]] = genericArrayOps(arr).transpose(using asArray.asInstanceOf[T => Array[U]])