@@ -3,7 +3,7 @@ import reflect.ClassTag
3
3
4
4
import scala .collection .{LazyZip2 , SeqView , Searching , Stepper , StepperShape }
5
5
import scala .collection .immutable .ArraySeq
6
- import scala .collection .mutable .IArrayBuilder
6
+ import scala .collection .mutable .{ ArrayBuilder , Builder }
7
7
8
8
opaque type IArray [+ T ] = Array [_ <: T ]
9
9
@@ -440,8 +440,8 @@ object IArray:
440
440
def from [A : ClassTag ](it : IterableOnce [A ]): Array [A ] =
441
441
Array .from(it)
442
442
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)
445
445
446
446
/** Concatenates all arrays into a single immutable array.
447
447
*
@@ -635,7 +635,7 @@ object IArray:
635
635
* `f` to each element of this array and collecting the results.
636
636
*/
637
637
def map [U : ClassTag ](f : T => U ): IArray [U ] = {
638
- val b = IArrayBuilder .make [U ]
638
+ val b = IArray .newBuilder [U ]
639
639
var i = 0
640
640
while (i < xs.length) {
641
641
val x = xs(i)
@@ -654,7 +654,7 @@ object IArray:
654
654
* `f` to each element of this array and concatenating the results.
655
655
*/
656
656
def flatMap [U : ClassTag ](f : T => IterableOnce [U ]): IArray [U ] = {
657
- val b = IArrayBuilder .make [U ]
657
+ val b = IArray .newBuilder [U ]
658
658
var i = 0
659
659
while (i < xs.length) {
660
660
val x = xs(i)
0 commit comments