Skip to content

Commit 91902f7

Browse files
committed
wip: sling @uncheckedVariance around some more
1 parent b78cd00 commit 91902f7

File tree

4 files changed

+16
-14
lines changed

4 files changed

+16
-14
lines changed

core/src/main/scala/scala/collection/generic/GenericTraversableTemplate.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ trait GenericTraversableTemplate[+A, +CC[X] <: ParIterable[X]] extends HasNewBui
6363

6464
/** The builder that builds instances of type $Coll[A]
6565
*/
66-
protected[this] def newBuilder: Builder[A, CC[A]] = companion.newBuilder[A]
66+
protected[this] def newBuilder: Builder[A @uncheckedVariance, CC[A @uncheckedVariance]] = companion.newBuilder[A]
6767

6868
/** The generic builder that builds instances of $Coll
6969
* at arbitrary element types.

core/src/main/scala/scala/collection/generic/HasNewBuilder.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ package collection
1515
package generic
1616

1717
import mutable.Builder
18+
import scala.annotation.unchecked.uncheckedVariance
1819

1920
trait HasNewBuilder[+A, +Repr] extends Any {
2021
/** The builder that builds instances of Repr */
21-
protected[this] def newBuilder: Builder[A, Repr]
22+
protected[this] def newBuilder: Builder[A @uncheckedVariance, Repr]
2223
}

core/src/main/scala/scala/collection/generic/HasNewCombiner.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ package collection
1515
package generic
1616

1717
import scala.collection.parallel.Combiner
18+
import scala.annotation.unchecked.uncheckedVariance
1819

1920
trait HasNewCombiner[+T, +Repr] {
20-
protected[this] def newCombiner: Combiner[T, Repr]
21+
protected[this] def newCombiner: Combiner[T @uncheckedVariance, Repr]
2122
}
2223

core/src/main/scala/scala/collection/parallel/ParIterableLike.scala

+11-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import scala.collection.{CustomParallelizable, IterableOps, Parallel}
2020
import scala.collection.generic._
2121
import immutable.HashMapCombiner
2222
import scala.reflect.ClassTag
23-
23+
import scala.annotation.unchecked.uncheckedVariance
2424

2525
/** A template trait for parallel collections of type `ParIterable[T]`.
2626
*
@@ -145,10 +145,10 @@ import scala.reflect.ClassTag
145145
* @define coll parallel iterable
146146
*/
147147
trait ParIterableLike[+T, +CC[X] <: ParIterable[X], +Repr <: ParIterable[T], +Sequential <: Iterable[T] with IterableOps[T, Iterable, Sequential]]
148-
extends IterableOnce[T]
149-
with CustomParallelizable[T, Repr]
148+
extends IterableOnce[T @uncheckedVariance]
149+
with CustomParallelizable[T @uncheckedVariance, Repr]
150150
with Parallel
151-
with HasNewCombiner[T, Repr]
151+
with HasNewCombiner[T @uncheckedVariance, Repr]
152152
{
153153
self =>
154154

@@ -850,7 +850,7 @@ self =>
850850
protected trait Accessor[R, Tp]
851851
extends StrictSplitterCheckTask[R, Tp] {
852852
protected[this] val pit: IterableSplitter[T]
853-
protected[this] def newSubtask(p: IterableSplitter[T]): Accessor[R, Tp]
853+
protected[this] def newSubtask(p: IterableSplitter[T @uncheckedVariance]): Accessor[R, Tp]
854854
def shouldSplitFurther = pit.shouldSplitFurther(self.repr, tasksupport.parallelismLevel)
855855
def split = pit.splitWithSignalling.map(newSubtask(_)) // default split procedure
856856
private[parallel] override def signalAbort() = pit.abort()
@@ -919,28 +919,28 @@ self =>
919919

920920
protected trait Transformer[R, Tp] extends Accessor[R, Tp] { }
921921

922-
protected[this] class Foreach[S](op: T => S, protected[this] val pit: IterableSplitter[T])
922+
protected[this] class Foreach[S](op: T => S, protected[this] val pit: IterableSplitter[T @uncheckedVariance])
923923
extends Accessor[Unit, Foreach[S]] {
924924
@volatile var result: Unit = ()
925925
def leaf(prevr: Option[Unit]) = pit.foreach(op)
926-
protected[this] def newSubtask(p: IterableSplitter[T]) = new Foreach[S](op, p)
926+
protected[this] def newSubtask(p: IterableSplitter[T @uncheckedVariance]) = new Foreach[S](op, p)
927927
}
928928

929-
protected[this] class Count(pred: T => Boolean, protected[this] val pit: IterableSplitter[T])
929+
protected[this] class Count(pred: T => Boolean, protected[this] val pit: IterableSplitter[T @uncheckedVariance])
930930
extends Accessor[Int, Count] {
931931
// val pittxt = pit.toString
932932
@volatile var result: Int = 0
933933
def leaf(prevr: Option[Int]) = result = pit.count(pred)
934-
protected[this] def newSubtask(p: IterableSplitter[T]) = new Count(pred, p)
934+
protected[this] def newSubtask(p: IterableSplitter[T @uncheckedVariance]) = new Count(pred, p)
935935
override def merge(that: Count) = result = result + that.result
936936
// override def toString = "CountTask(" + pittxt + ")"
937937
}
938938

939-
protected[this] class Reduce[U >: T](op: (U, U) => U, protected[this] val pit: IterableSplitter[T])
939+
protected[this] class Reduce[U >: T](op: (U, U) => U, protected[this] val pit: IterableSplitter[T @uncheckedVariance])
940940
extends Accessor[Option[U], Reduce[U]] {
941941
@volatile var result: Option[U] = None
942942
def leaf(prevr: Option[Option[U]]) = if (pit.remaining > 0) result = Some(pit.reduce(op))
943-
protected[this] def newSubtask(p: IterableSplitter[T]) = new Reduce(op, p)
943+
protected[this] def newSubtask(p: IterableSplitter[T @uncheckedVariance]) = new Reduce(op, p)
944944
override def merge(that: Reduce[U]) =
945945
if (this.result == None) result = that.result
946946
else if (that.result != None) result = Some(op(result.get, that.result.get))

0 commit comments

Comments
 (0)