Skip to content

Commit de523ad

Browse files
authored
Merge pull request #115 from SethTisue/fix-2.13
adapt to post 2.13.0-M4 changes
2 parents 8551932 + da3bef5 commit de523ad

File tree

2 files changed

+100
-74
lines changed

2 files changed

+100
-74
lines changed

src/main/scala/scala/compat/java8/StreamConverters.scala

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -221,52 +221,58 @@ with converterImpl.Priority1AccumulatorConverters
221221
def parStream: LongStream = seqStream.parallel
222222
}
223223

224-
implicit val primitiveAccumulateDoubleStream = new PrimitiveStreamAccumulator[Stream[Double], DoubleAccumulator] {
225-
def streamAccumulate(stream: Stream[Double]): DoubleAccumulator =
226-
stream.collect(DoubleAccumulator.supplier, DoubleAccumulator.boxedAdder, DoubleAccumulator.merger)
227-
}
228-
229-
implicit val primitiveAccumulateDoubleStream2 =
224+
implicit val primitiveAccumulateDoubleStream: PrimitiveStreamAccumulator[Stream[Double], DoubleAccumulator] =
225+
new PrimitiveStreamAccumulator[Stream[Double], DoubleAccumulator] {
226+
def streamAccumulate(stream: Stream[Double]): DoubleAccumulator =
227+
stream.collect(DoubleAccumulator.supplier, DoubleAccumulator.boxedAdder, DoubleAccumulator.merger)
228+
}
229+
230+
implicit val primitiveAccumulateDoubleStream2: PrimitiveStreamAccumulator[Stream[java.lang.Double], DoubleAccumulator] =
230231
primitiveAccumulateDoubleStream.asInstanceOf[PrimitiveStreamAccumulator[Stream[java.lang.Double], DoubleAccumulator]]
231-
232-
implicit val primitiveUnboxDoubleStream = new PrimitiveStreamUnboxer[Double, DoubleStream] {
233-
def apply(boxed: Stream[Double]): DoubleStream =
234-
boxed.mapToDouble(new java.util.function.ToDoubleFunction[Double]{ def applyAsDouble(d: Double) = d })
235-
}
236-
237-
implicit val primitiveUnboxDoubleStream2 =
232+
233+
implicit val primitiveUnboxDoubleStream: PrimitiveStreamUnboxer[Double, DoubleStream] =
234+
new PrimitiveStreamUnboxer[Double, DoubleStream] {
235+
def apply(boxed: Stream[Double]): DoubleStream =
236+
boxed.mapToDouble(new java.util.function.ToDoubleFunction[Double]{ def applyAsDouble(d: Double) = d })
237+
}
238+
239+
implicit val primitiveUnboxDoubleStream2: PrimitiveStreamUnboxer[java.lang.Double, DoubleStream] =
238240
primitiveUnboxDoubleStream.asInstanceOf[PrimitiveStreamUnboxer[java.lang.Double, DoubleStream]]
239-
240-
implicit val primitiveAccumulateIntStream = new PrimitiveStreamAccumulator[Stream[Int], IntAccumulator] {
241-
def streamAccumulate(stream: Stream[Int]): IntAccumulator =
242-
stream.collect(IntAccumulator.supplier, IntAccumulator.boxedAdder, IntAccumulator.merger)
243-
}
244241

245-
implicit val primitiveAccumulateIntStream2 =
242+
implicit val primitiveAccumulateIntStream: PrimitiveStreamAccumulator[Stream[Int], IntAccumulator] =
243+
new PrimitiveStreamAccumulator[Stream[Int], IntAccumulator] {
244+
def streamAccumulate(stream: Stream[Int]): IntAccumulator =
245+
stream.collect(IntAccumulator.supplier, IntAccumulator.boxedAdder, IntAccumulator.merger)
246+
}
247+
248+
implicit val primitiveAccumulateIntStream2: PrimitiveStreamAccumulator[Stream[java.lang.Integer], IntAccumulator] =
246249
primitiveAccumulateIntStream.asInstanceOf[PrimitiveStreamAccumulator[Stream[java.lang.Integer], IntAccumulator]]
247-
248-
implicit val primitiveUnboxIntStream = new PrimitiveStreamUnboxer[Int, IntStream] {
249-
def apply(boxed: Stream[Int]): IntStream =
250-
boxed.mapToInt(new java.util.function.ToIntFunction[Int]{ def applyAsInt(d: Int) = d })
251-
}
252-
253-
implicit val primitiveUnboxIntStream2 =
250+
251+
implicit val primitiveUnboxIntStream: PrimitiveStreamUnboxer[Int, IntStream] =
252+
new PrimitiveStreamUnboxer[Int, IntStream] {
253+
def apply(boxed: Stream[Int]): IntStream =
254+
boxed.mapToInt(new java.util.function.ToIntFunction[Int]{ def applyAsInt(d: Int) = d })
255+
}
256+
257+
implicit val primitiveUnboxIntStream2: PrimitiveStreamUnboxer[java.lang.Integer, IntStream] =
254258
primitiveUnboxIntStream.asInstanceOf[PrimitiveStreamUnboxer[java.lang.Integer, IntStream]]
255-
256-
implicit val primitiveAccumulateLongStream = new PrimitiveStreamAccumulator[Stream[Long], LongAccumulator] {
257-
def streamAccumulate(stream: Stream[Long]): LongAccumulator =
258-
stream.collect(LongAccumulator.supplier, LongAccumulator.boxedAdder, LongAccumulator.merger)
259-
}
260259

261-
implicit val primitiveAccumulateLongStream2 =
260+
implicit val primitiveAccumulateLongStream: PrimitiveStreamAccumulator[Stream[Long], LongAccumulator] =
261+
new PrimitiveStreamAccumulator[Stream[Long], LongAccumulator] {
262+
def streamAccumulate(stream: Stream[Long]): LongAccumulator =
263+
stream.collect(LongAccumulator.supplier, LongAccumulator.boxedAdder, LongAccumulator.merger)
264+
}
265+
266+
implicit val primitiveAccumulateLongStream2: PrimitiveStreamAccumulator[Stream[java.lang.Long], LongAccumulator] =
262267
primitiveAccumulateLongStream.asInstanceOf[PrimitiveStreamAccumulator[Stream[java.lang.Long], LongAccumulator]]
263-
264-
implicit val primitiveUnboxLongStream = new PrimitiveStreamUnboxer[Long, LongStream] {
265-
def apply(boxed: Stream[Long]): LongStream =
266-
boxed.mapToLong(new java.util.function.ToLongFunction[Long]{ def applyAsLong(d: Long) = d })
267-
}
268-
269-
implicit val primitiveUnboxLongStream2 =
268+
269+
implicit val primitiveUnboxLongStream: PrimitiveStreamUnboxer[Long, LongStream] =
270+
new PrimitiveStreamUnboxer[Long, LongStream] {
271+
def apply(boxed: Stream[Long]): LongStream =
272+
boxed.mapToLong(new java.util.function.ToLongFunction[Long]{ def applyAsLong(d: Long) = d })
273+
}
274+
275+
implicit val primitiveUnboxLongStream2: PrimitiveStreamUnboxer[java.lang.Long, LongStream] =
270276
primitiveUnboxLongStream.asInstanceOf[PrimitiveStreamUnboxer[java.lang.Long, LongStream]]
271277

272278
implicit final class RichDoubleStream(private val stream: DoubleStream) extends AnyVal {
@@ -308,27 +314,30 @@ with converterImpl.Priority1AccumulatorConverters
308314
}
309315
}
310316

311-
implicit val accumulateDoubleStepper = new AccumulatesFromStepper[Double, DoubleAccumulator] {
312-
def apply(stepper: Stepper[Double]) = {
313-
val a = new DoubleAccumulator
314-
while (stepper.hasStep) a += stepper.nextStep
315-
a
317+
implicit val accumulateDoubleStepper: AccumulatesFromStepper[Double, DoubleAccumulator] =
318+
new AccumulatesFromStepper[Double, DoubleAccumulator] {
319+
def apply(stepper: Stepper[Double]) = {
320+
val a = new DoubleAccumulator
321+
while (stepper.hasStep) a += stepper.nextStep
322+
a
323+
}
316324
}
317-
}
318325

319-
implicit val accumulateIntStepper = new AccumulatesFromStepper[Int, IntAccumulator] {
320-
def apply(stepper: Stepper[Int]) = {
321-
val a = new IntAccumulator
322-
while (stepper.hasStep) a += stepper.nextStep
323-
a
326+
implicit val accumulateIntStepper: AccumulatesFromStepper[Int, IntAccumulator] =
327+
new AccumulatesFromStepper[Int, IntAccumulator] {
328+
def apply(stepper: Stepper[Int]) = {
329+
val a = new IntAccumulator
330+
while (stepper.hasStep) a += stepper.nextStep
331+
a
332+
}
324333
}
325-
}
326334

327-
implicit val accumulateLongStepper = new AccumulatesFromStepper[Long, LongAccumulator] {
328-
def apply(stepper: Stepper[Long]) = {
329-
val a = new LongAccumulator
330-
while (stepper.hasStep) a += stepper.nextStep
331-
a
335+
implicit val accumulateLongStepper: AccumulatesFromStepper[Long, LongAccumulator] =
336+
new AccumulatesFromStepper[Long, LongAccumulator] {
337+
def apply(stepper: Stepper[Long]) = {
338+
val a = new LongAccumulator
339+
while (stepper.hasStep) a += stepper.nextStep
340+
a
341+
}
332342
}
333-
}
334343
}

src/main/scala/scala/compat/java8/converterImpl/StepConverters.scala

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,44 @@ import language.implicitConversions
55
import scala.reflect.ClassTag
66

77
trait Priority3StepConverters {
8-
implicit def richIterableCanStep[A](underlying: Iterable[A]) = new RichIterableCanStep(underlying)
9-
implicit def richMapCanStep[K, V](underlying: collection.Map[K, V]) = new RichMapCanStep[K, V](underlying)
8+
implicit def richIterableCanStep[A](underlying: Iterable[A]): RichIterableCanStep[A] =
9+
new RichIterableCanStep(underlying)
10+
implicit def richMapCanStep[K, V](underlying: collection.Map[K, V]): RichMapCanStep[K, V] =
11+
new RichMapCanStep[K, V](underlying)
1012
}
1113

1214
trait Priority2StepConverters extends Priority3StepConverters {
13-
implicit def richLinearSeqCanStep[A](underlying: collection.LinearSeq[A]) = new RichLinearSeqCanStep[A](underlying)
14-
implicit def richIndexedSeqCanStep[A](underlying: collection.IndexedSeqOps[A, Any, _]) = new RichIndexedSeqCanStep[A](underlying)
15+
implicit def richLinearSeqCanStep[A](underlying: collection.LinearSeq[A]): RichLinearSeqCanStep[A] =
16+
new RichLinearSeqCanStep[A](underlying)
17+
implicit def richIndexedSeqCanStep[A](underlying: collection.IndexedSeqOps[A, Any, _]): RichIndexedSeqCanStep[A] =
18+
new RichIndexedSeqCanStep[A](underlying)
1519
}
1620

1721
trait Priority1StepConverters extends Priority2StepConverters {
18-
implicit def richDefaultHashMapCanStep[K, V](underlying: collection.mutable.HashMap[K, V]) = new RichHashMapCanStep[K, V](underlying)
19-
implicit def richLinkedHashMapCanStep[K, V](underlying: collection.mutable.LinkedHashMap[K, V]) = new RichLinkedHashMapCanStep[K, V](underlying)
20-
implicit def richArrayCanStep[A](underlying: Array[A]) = new RichArrayCanStep[A](underlying)
21-
implicit def richArraySeqCanStep[A: ClassTag](underlying: collection.mutable.ArraySeq[A]) = new RichArrayCanStep[A](StreamConverters.unsafeArrayIfPossible(underlying))
22-
implicit def richHashSetCanStep[A](underlying: collection.mutable.HashSet[A]) = new RichHashSetCanStep[A](underlying)
23-
implicit def richIteratorCanStep[A](underlying: Iterator[A]) = new RichIteratorCanStep(underlying)
24-
implicit def richImmHashMapCanStep[K, V](underlying: collection.immutable.HashMap[K, V]) = new RichImmHashMapCanStep[K, V](underlying)
25-
implicit def richImmHashSetCanStep[A](underlying: collection.immutable.HashSet[A]) = new RichImmHashSetCanStep[A](underlying)
26-
implicit def richNumericRangeCanStep[T](underlying: collection.immutable.NumericRange[T]) = new RichNumericRangeCanStep(underlying)
27-
implicit def richVectorCanStep[A](underlying: Vector[A]) = new RichVectorCanStep[A](underlying)
28-
implicit def richBitSetCanStep(underlying: collection.BitSet) = new RichBitSetCanStep(underlying)
29-
implicit def richRangeCanStep(underlying: Range) = new RichRangeCanStep(underlying)
30-
implicit def richStringCanStep(underlying: String) = new RichStringCanStep(underlying)
22+
implicit def richDefaultHashMapCanStep[K, V](underlying: collection.mutable.HashMap[K, V]): RichHashMapCanStep[K, V] =
23+
new RichHashMapCanStep[K, V](underlying)
24+
implicit def richLinkedHashMapCanStep[K, V](underlying: collection.mutable.LinkedHashMap[K, V]): RichLinkedHashMapCanStep[K, V] =
25+
new RichLinkedHashMapCanStep[K, V](underlying)
26+
implicit def richArrayCanStep[A](underlying: Array[A]): RichArrayCanStep[A] =
27+
new RichArrayCanStep[A](underlying)
28+
implicit def richArraySeqCanStep[A: ClassTag](underlying: collection.mutable.ArraySeq[A]): RichArrayCanStep[A] =
29+
new RichArrayCanStep[A](StreamConverters.unsafeArrayIfPossible(underlying))
30+
implicit def richHashSetCanStep[A](underlying: collection.mutable.HashSet[A]): RichHashSetCanStep[A] =
31+
new RichHashSetCanStep[A](underlying)
32+
implicit def richIteratorCanStep[A](underlying: Iterator[A]): RichIteratorCanStep[A] =
33+
new RichIteratorCanStep(underlying)
34+
implicit def richImmHashMapCanStep[K, V](underlying: collection.immutable.HashMap[K, V]): RichImmHashMapCanStep[K, V] =
35+
new RichImmHashMapCanStep[K, V](underlying)
36+
implicit def richImmHashSetCanStep[A](underlying: collection.immutable.HashSet[A]): RichImmHashSetCanStep[A] =
37+
new RichImmHashSetCanStep[A](underlying)
38+
implicit def richNumericRangeCanStep[T](underlying: collection.immutable.NumericRange[T]): RichNumericRangeCanStep[T] =
39+
new RichNumericRangeCanStep(underlying)
40+
implicit def richVectorCanStep[A](underlying: Vector[A]): RichVectorCanStep[A] =
41+
new RichVectorCanStep[A](underlying)
42+
implicit def richBitSetCanStep(underlying: collection.BitSet): RichBitSetCanStep =
43+
new RichBitSetCanStep(underlying)
44+
implicit def richRangeCanStep(underlying: Range): RichRangeCanStep[Int] =
45+
new RichRangeCanStep(underlying)
46+
implicit def richStringCanStep(underlying: String): RichStringCanStep =
47+
new RichStringCanStep(underlying)
3148
}

0 commit comments

Comments
 (0)