Skip to content

Adapt to 2.13.0-RC3 #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jdk:
- openjdk11

scala:
- 2.13.0-RC2
- 2.13.0-RC3

env:
global:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ScalaModulePlugin._

crossScalaVersions in ThisBuild := List("2.13.0-RC2")
crossScalaVersions in ThisBuild := List("2.13.0-RC3")

val disableDocs =
sys.props("nodocs") == "true" ||
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/scala/compat/java8/ScalaStreamSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static <K> Stream<K> streamKeys(Map<K, ?> coll) {
* @return A Stream view of the collection which, by default, executes sequentially.
*/
public static <V> Stream<V> streamValues(Map<?, V> coll) {
return StreamSupport.stream(coll.<V, AnyStepper<V>>valueStepper(StepperShape.anyStepperShape()).spliterator(), false);
return StreamSupport.stream(coll.<AnyStepper<V>>valueStepper(StepperShape.anyStepperShape()).spliterator(), false);
}

/**
Expand Down
26 changes: 13 additions & 13 deletions src/main/scala/scala/compat/java8/StreamConverters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ trait StreamExtensions {
s.fromStepper(cc.stepper, par = false)
}

protected type IterableOnceWithEfficientStepper[A] = IterableOnce[A] {
def stepper[B >: A, S <: Stepper[_]](implicit shape : StepperShape[B, S]) : S with EfficientSplit
}

// Not `CC[X] <: IterableOnce[X]`, but `C` with an extra constraint, to support non-parametric classes like IntAccumulator
implicit class IterableNonGenericHasParStream[A, C <: IterableOnce[_]](c: C)(implicit ev: C <:< IterableOnce[A]) {
private type IterableOnceWithEfficientStepper = IterableOnce[A] {
def stepper[S <: Stepper[_]](implicit shape : StepperShape[A, S]) : S with EfficientSplit
}

/** Create a parallel [[java.util.stream.Stream Java Stream]] for this collection. If the
* collection contains primitive values, a corresponding specialized Stream is returned (e.g.,
* [[java.util.stream.IntStream `IntStream`]]).
Expand All @@ -55,13 +55,13 @@ trait StreamExtensions {
s: StreamShape[A, S, St],
st: StepperShape[A, St],
@implicitNotFound("`parStream` can only be called on collections where `stepper` returns a `Stepper with EfficientSplit`")
isEfficient: C <:< IterableOnceWithEfficientStepper[A]): S =
isEfficient: C <:< IterableOnceWithEfficientStepper): S =
s.fromStepper(ev(c).stepper, par = true)
}

// maps

implicit class MapHasSeqKeyValueStream[K, V, CC[X, Y] <: collection.MapOps[X, Y, CC, _]](cc: CC[K, V]) {
implicit class MapHasSeqKeyValueStream[K, V, CC[X, Y] <: collection.MapOps[X, Y, collection.Map, _]](cc: CC[K, V]) {
/** Create a sequential [[java.util.stream.Stream Java Stream]] for the keys of this map. If
* the keys are primitive values, a corresponding specialized Stream is returned (e.g.,
* [[java.util.stream.IntStream `IntStream`]]).
Expand All @@ -85,10 +85,10 @@ trait StreamExtensions {
}


implicit class MapHasParKeyValueStream[K, V, CC[X, Y] <: collection.MapOps[X, Y, CC, _]](cc: CC[K, V]) {
private type MapOpsWithEfficientKeyStepper[K, V] = collection.MapOps[K, V, CC, _] { def keyStepper[S <: Stepper[_]](implicit shape : StepperShape[K, S]) : S with EfficientSplit }
private type MapOpsWithEfficientValueStepper[K, V] = collection.MapOps[K, V, CC, _] { def valueStepper[V1 >: V, S <: Stepper[_]](implicit shape : StepperShape[V1, S]) : S with EfficientSplit }
private type MapOpsWithEfficientStepper[K, V] = collection.MapOps[K, V, CC, _] { def stepper[B >: (K, V), S <: Stepper[_]](implicit shape : StepperShape[B, S]) : S with EfficientSplit }
implicit class MapHasParKeyValueStream[K, V, CC[X, Y] <: collection.MapOps[X, Y, collection.Map, _]](cc: CC[K, V]) {
private type MapOpsWithEfficientKeyStepper = collection.MapOps[K, V, collection.Map, _] { def keyStepper[S <: Stepper[_]](implicit shape : StepperShape[K, S]) : S with EfficientSplit }
private type MapOpsWithEfficientValueStepper = collection.MapOps[K, V, collection.Map, _] { def valueStepper[V1 >: V, S <: Stepper[_]](implicit shape : StepperShape[V1, S]) : S with EfficientSplit }
private type MapOpsWithEfficientStepper = collection.MapOps[K, V, collection.Map, _] { def stepper[S <: Stepper[_]](implicit shape : StepperShape[(K, V), S]) : S with EfficientSplit }

/** Create a parallel [[java.util.stream.Stream Java Stream]] for the keys of this map. If
* the keys are primitive values, a corresponding specialized Stream is returned (e.g.,
Expand All @@ -98,7 +98,7 @@ trait StreamExtensions {
s: StreamShape[K, S, St],
st: StepperShape[K, St],
@implicitNotFound("parKeyStream can only be called on maps where `keyStepper` returns a `Stepper with EfficientSplit`")
isEfficient: CC[K, V] <:< MapOpsWithEfficientKeyStepper[K, V]): S =
isEfficient: CC[K, V] <:< MapOpsWithEfficientKeyStepper): S =
s.fromStepper(cc.keyStepper, par = true)

/** Create a parallel [[java.util.stream.Stream Java Stream]] for the values of this map. If
Expand All @@ -109,7 +109,7 @@ trait StreamExtensions {
s: StreamShape[V, S, St],
st: StepperShape[V, St],
@implicitNotFound("parValueStream can only be called on maps where `valueStepper` returns a `Stepper with EfficientSplit`")
isEfficient: CC[K, V] <:< MapOpsWithEfficientValueStepper[K, V]): S =
isEfficient: CC[K, V] <:< MapOpsWithEfficientValueStepper): S =
s.fromStepper(cc.valueStepper, par = true)

// The parStream extension method for IterableOnce doesn't apply because its `CC` takes a single type parameter, whereas the one here takes two
Expand All @@ -120,7 +120,7 @@ trait StreamExtensions {
s: StreamShape[(K, V), S, St],
st: StepperShape[(K, V), St],
@implicitNotFound("parStream can only be called on maps where `stepper` returns a `Stepper with EfficientSplit`")
isEfficient: CC[K, V] <:< MapOpsWithEfficientStepper[K, V]): S =
isEfficient: CC[K, V] <:< MapOpsWithEfficientStepper): S =
s.fromStepper(cc.stepper, par = true)
}

Expand Down