@@ -188,11 +188,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
188
188
case that : ofRef[_] => Arrays .equals(unsafeArray.asInstanceOf [Array [AnyRef ]], that.unsafeArray.asInstanceOf [Array [AnyRef ]])
189
189
case _ => super .equals(that)
190
190
}
191
- override def slice (from : Int , until : Int ): ImmutableArray [T ] = {
191
+ override def slice (from : Int , until : Int ): ImmutableArray .ofRef [T ] = {
192
192
val lo = scala.math.max(from, 0 )
193
193
val hi = scala.math.min(until, length)
194
194
if (lo >= hi)
195
- emptyImpl
195
+ emptyImpl. asInstanceOf [ofRef[ T ]]
196
196
else
197
197
new ofRef(Arrays .copyOfRange[T ](unsafeArray, lo, hi))
198
198
}
@@ -213,7 +213,7 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
213
213
val lo = scala.math.max(from, 0 )
214
214
val hi = scala.math.min(until, length)
215
215
if (lo >= hi)
216
- emptyImpl
216
+ new ofByte( Array .emptyByteArray)
217
217
else
218
218
new ofByte(Arrays .copyOfRange(unsafeArray, lo, hi))
219
219
}
@@ -230,11 +230,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
230
230
case that : ofShort => Arrays .equals(unsafeArray, that.unsafeArray)
231
231
case _ => super .equals(that)
232
232
}
233
- override def slice (from : Int , until : Int ): ImmutableArray [ Short ] = {
233
+ override def slice (from : Int , until : Int ): ImmutableArray .ofShort = {
234
234
val lo = scala.math.max(from, 0 )
235
235
val hi = scala.math.min(until, length)
236
236
if (lo >= hi)
237
- emptyImpl
237
+ new ofShort( Array .emptyShortArray)
238
238
else
239
239
new ofShort(Arrays .copyOfRange(unsafeArray, lo, hi))
240
240
}
@@ -251,11 +251,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
251
251
case that : ofChar => Arrays .equals(unsafeArray, that.unsafeArray)
252
252
case _ => super .equals(that)
253
253
}
254
- override def slice (from : Int , until : Int ): ImmutableArray [ Char ] = {
254
+ override def slice (from : Int , until : Int ): ImmutableArray .ofChar = {
255
255
val lo = scala.math.max(from, 0 )
256
256
val hi = scala.math.min(until, length)
257
257
if (lo >= hi)
258
- emptyImpl
258
+ new ofChar( Array .emptyCharArray)
259
259
else
260
260
new ofChar(Arrays .copyOfRange(unsafeArray, lo, hi))
261
261
}
@@ -272,11 +272,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
272
272
case that : ofInt => Arrays .equals(unsafeArray, that.unsafeArray)
273
273
case _ => super .equals(that)
274
274
}
275
- override def slice (from : Int , until : Int ): ImmutableArray [ Int ] = {
275
+ override def slice (from : Int , until : Int ): ImmutableArray .ofInt = {
276
276
val lo = scala.math.max(from, 0 )
277
277
val hi = scala.math.min(until, length)
278
278
if (lo >= hi)
279
- emptyImpl
279
+ new ofInt( Array .emptyIntArray)
280
280
else
281
281
new ofInt(Arrays .copyOfRange(unsafeArray, lo, hi))
282
282
}
@@ -293,11 +293,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
293
293
case that : ofLong => Arrays .equals(unsafeArray, that.unsafeArray)
294
294
case _ => super .equals(that)
295
295
}
296
- override def slice (from : Int , until : Int ): ImmutableArray [ Long ] = {
296
+ override def slice (from : Int , until : Int ): ImmutableArray .ofLong = {
297
297
val lo = scala.math.max(from, 0 )
298
298
val hi = scala.math.min(until, length)
299
299
if (lo >= hi)
300
- emptyImpl
300
+ new ofLong( Array .emptyLongArray)
301
301
else
302
302
new ofLong(Arrays .copyOfRange(unsafeArray, lo, hi))
303
303
}
@@ -314,11 +314,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
314
314
case that : ofFloat => Arrays .equals(unsafeArray, that.unsafeArray)
315
315
case _ => super .equals(that)
316
316
}
317
- override def slice (from : Int , until : Int ): ImmutableArray [ Float ] = {
317
+ override def slice (from : Int , until : Int ): ImmutableArray .ofFloat = {
318
318
val lo = scala.math.max(from, 0 )
319
319
val hi = scala.math.min(until, length)
320
320
if (lo >= hi)
321
- emptyImpl
321
+ new ofFloat( Array .emptyFloatArray)
322
322
else
323
323
new ofFloat(Arrays .copyOfRange(unsafeArray, lo, hi))
324
324
}
@@ -335,11 +335,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
335
335
case that : ofDouble => Arrays .equals(unsafeArray, that.unsafeArray)
336
336
case _ => super .equals(that)
337
337
}
338
- override def slice (from : Int , until : Int ): ImmutableArray [ Double ] = {
338
+ override def slice (from : Int , until : Int ): ImmutableArray .ofDouble = {
339
339
val lo = scala.math.max(from, 0 )
340
340
val hi = scala.math.min(until, length)
341
341
if (lo >= hi)
342
- emptyImpl
342
+ new ofDouble( new Array [ Double ]( 0 ))
343
343
else
344
344
new ofDouble(Arrays .copyOfRange(unsafeArray, lo, hi))
345
345
}
@@ -356,11 +356,11 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
356
356
case that : ofBoolean => Arrays .equals(unsafeArray, that.unsafeArray)
357
357
case _ => super .equals(that)
358
358
}
359
- override def slice (from : Int , until : Int ): ImmutableArray [ Boolean ] = {
359
+ override def slice (from : Int , until : Int ): ImmutableArray .ofBoolean = {
360
360
val lo = scala.math.max(from, 0 )
361
361
val hi = scala.math.min(until, length)
362
362
if (lo >= hi)
363
- emptyImpl
363
+ new ofBoolean( Array .emptyBooleanArray)
364
364
else
365
365
new ofBoolean(Arrays .copyOfRange(unsafeArray, lo, hi))
366
366
}
@@ -377,18 +377,17 @@ object ImmutableArray extends StrictOptimizedClassTagSeqFactory[ImmutableArray]
377
377
case that : ofUnit => unsafeArray.length == that.unsafeArray.length
378
378
case _ => super .equals(that)
379
379
}
380
- override def slice (from : Int , until : Int ): ImmutableArray [ Unit ] = {
380
+ override def slice (from : Int , until : Int ): ImmutableArray .ofUnit = {
381
381
// cant use
382
382
// new ofUnit(util.Arrays.copyOfRange[Unit](array, from, until)) - Unit is special and doesnt compile
383
383
// cant use util.Arrays.copyOfRange[Unit](repr, from, until) - Unit is special and doesnt compile
384
384
val lo = scala.math.max(from, 0 )
385
385
val hi = scala.math.min(until, length)
386
386
val slicedLength = hi - lo
387
387
if (slicedLength <= 0 )
388
- emptyImpl
388
+ new ofUnit( new Array [ Unit ]( 0 ))
389
389
else {
390
- val res = new Array [Unit ](slicedLength)
391
- new ofUnit(res)
390
+ new ofUnit(new Array [Unit ](slicedLength))
392
391
}
393
392
}
394
393
}
0 commit comments