@@ -3,7 +3,7 @@ import reflect.ClassTag
33
44import scala .collection .{LazyZip2 , SeqView , Searching , Stepper , StepperShape }
55import scala .collection .immutable .ArraySeq
6- import scala .collection .mutable .IArrayBuilder
6+ import scala .collection .mutable .{ ArrayBuilder , Builder }
77
88opaque type IArray [+ T ] = Array [_ <: T ]
99
@@ -440,8 +440,8 @@ object IArray:
440440 def from [A : ClassTag ](it : IterableOnce [A ]): Array [A ] =
441441 Array .from(it)
442442
443- def newBuilder [T ](using t : ClassTag [T ]): IArrayBuilder [ T ] =
444- IArrayBuilder .make[T ]
443+ def newBuilder [T ](using t : ClassTag [T ]): Builder [ T , IArray [ T ] ] =
444+ ArrayBuilder .make[T ].mapResult( IArray .unsafeFromArray)
445445
446446 /** Concatenates all arrays into a single immutable array.
447447 *
@@ -635,7 +635,7 @@ object IArray:
635635 * `f` to each element of this array and collecting the results.
636636 */
637637 def map [U : ClassTag ](f : T => U ): IArray [U ] = {
638- val b = IArrayBuilder .make [U ]
638+ val b = IArray .newBuilder [U ]
639639 var i = 0
640640 while (i < xs.length) {
641641 val x = xs(i)
@@ -654,7 +654,7 @@ object IArray:
654654 * `f` to each element of this array and concatenating the results.
655655 */
656656 def flatMap [U : ClassTag ](f : T => IterableOnce [U ]): IArray [U ] = {
657- val b = IArrayBuilder .make [U ]
657+ val b = IArray .newBuilder [U ]
658658 var i = 0
659659 while (i < xs.length) {
660660 val x = xs(i)
0 commit comments