Skip to content

Commit 6ebdf09

Browse files
committed
avoid nested class shadowing warnings
fixes #93
1 parent 3dbfbcc commit 6ebdf09

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ publish / skip := true // in root
33

44
lazy val commonSettings: Seq[Setting[_]] =
55
ScalaModulePlugin.scalaModuleSettings ++ Seq(
6-
Compile / compile / scalacOptions ++= Seq("-Werror", "-Wconf:cat=deprecation:msg=nested class of a parent:s")
6+
Compile / compile / scalacOptions += "-Werror"
77
)
88

99
lazy val core = project.in(file("core"))

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

+16-16
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ self =>
399399
that match {
400400
case thatseq: ParSeq[S] =>
401401
tasksupport.executeAndWaitResult(
402-
new Zip(length min thatseq.length, combinerFactory(() => companion.newCombiner[(U, S)]), splitter, thatseq.splitter) mapResult {
402+
new ParSeqLikeZip(length min thatseq.length, combinerFactory(() => companion.newCombiner[(U, S)]), splitter, thatseq.splitter) mapResult {
403403
_.resultWithTaskSupport
404404
}
405405
)
@@ -472,14 +472,14 @@ self =>
472472

473473
protected[this] def down(p: IterableSplitter[_]) = p.asInstanceOf[SeqSplitter[T]]
474474

475-
protected trait Accessor[R, Tp] extends super.Accessor[R, Tp] {
475+
protected trait ParSeqLikeAccessor[R, Tp] extends Accessor[R, Tp] {
476476
protected[this] val pit: SeqSplitter[T]
477477
}
478478

479-
protected trait Transformer[R, Tp] extends Accessor[R, Tp] with super.Transformer[R, Tp]
479+
protected trait ParSeqLikeTransformer[R, Tp] extends ParSeqLikeAccessor[R, Tp] with Transformer[R, Tp]
480480

481481
protected[this] class SegmentLength(pred: T => Boolean, from: Int, protected[this] val pit: SeqSplitter[T])
482-
extends Accessor[(Int, Boolean), SegmentLength] {
482+
extends ParSeqLikeAccessor[(Int, Boolean), SegmentLength] {
483483
@volatile var result: (Int, Boolean) = null
484484
def leaf(prev: Option[(Int, Boolean)]) = if (from < pit.indexFlag) {
485485
val itsize = pit.remaining
@@ -497,7 +497,7 @@ self =>
497497
}
498498

499499
protected[this] class IndexWhere(pred: T => Boolean, from: Int, protected[this] val pit: SeqSplitter[T])
500-
extends Accessor[Int, IndexWhere] {
500+
extends ParSeqLikeAccessor[Int, IndexWhere] {
501501
@volatile var result: Int = -1
502502
def leaf(prev: Option[Int]) = if (from < pit.indexFlag) {
503503
val r = pit.indexWhere(pred)
@@ -518,7 +518,7 @@ self =>
518518
}
519519

520520
protected[this] class LastIndexWhere(pred: T => Boolean, pos: Int, protected[this] val pit: SeqSplitter[T])
521-
extends Accessor[Int, LastIndexWhere] {
521+
extends ParSeqLikeAccessor[Int, LastIndexWhere] {
522522
@volatile var result: Int = -1
523523
def leaf(prev: Option[Int]) = if (pos > pit.indexFlag) {
524524
val r = pit.lastIndexWhere(pred)
@@ -539,23 +539,23 @@ self =>
539539
}
540540

541541
protected[this] class Reverse[U >: T, This >: Repr](cbf: () => Combiner[U, This], protected[this] val pit: SeqSplitter[T])
542-
extends Transformer[Combiner[U, This], Reverse[U, This]] {
542+
extends ParSeqLikeTransformer[Combiner[U, This], Reverse[U, This]] {
543543
@volatile var result: Combiner[U, This] = null
544544
def leaf(prev: Option[Combiner[U, This]]) = result = pit.reverse2combiner(reuse(prev, cbf()))
545545
protected[this] def newSubtask(p: SuperParIterator) = new Reverse(cbf, down(p))
546546
override def merge(that: Reverse[U, This]) = result = that.result combine result
547547
}
548548

549549
protected[this] class ReverseMap[S, That](f: T => S, pbf: () => Combiner[S, That], protected[this] val pit: SeqSplitter[T])
550-
extends Transformer[Combiner[S, That], ReverseMap[S, That]] {
550+
extends ParSeqLikeTransformer[Combiner[S, That], ReverseMap[S, That]] {
551551
@volatile var result: Combiner[S, That] = null
552552
def leaf(prev: Option[Combiner[S, That]]) = result = pit.reverseMap2combiner(f, pbf())
553553
protected[this] def newSubtask(p: SuperParIterator) = new ReverseMap(f, pbf, down(p))
554554
override def merge(that: ReverseMap[S, That]) = result = that.result combine result
555555
}
556556

557557
protected[this] class SameElements[U >: T](protected[this] val pit: SeqSplitter[T], val otherpit: SeqSplitter[U])
558-
extends Accessor[Boolean, SameElements[U]] {
558+
extends ParSeqLikeAccessor[Boolean, SameElements[U]] {
559559
@volatile var result: Boolean = true
560560
def leaf(prev: Option[Boolean]) = if (!pit.isAborted) {
561561
result = pit.sameElements(otherpit)
@@ -572,7 +572,7 @@ self =>
572572
}
573573

574574
protected[this] class Updated[U >: T, That](pos: Int, elem: U, pbf: CombinerFactory[U, That], protected[this] val pit: SeqSplitter[T])
575-
extends Transformer[Combiner[U, That], Updated[U, That]] {
575+
extends ParSeqLikeTransformer[Combiner[U, That], Updated[U, That]] {
576576
@volatile var result: Combiner[U, That] = null
577577
def leaf(prev: Option[Combiner[U, That]]) = result = pit.updated2combiner(pos, elem, pbf())
578578
protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException
@@ -584,8 +584,8 @@ self =>
584584
override def requiresStrictSplitters = true
585585
}
586586

587-
protected[this] class Zip[U >: T, S, That](len: Int, cf: CombinerFactory[(U, S), That], protected[this] val pit: SeqSplitter[T], val otherpit: SeqSplitter[S])
588-
extends Transformer[Combiner[(U, S), That], Zip[U, S, That]] {
587+
protected[this] class ParSeqLikeZip[U >: T, S, That](len: Int, cf: CombinerFactory[(U, S), That], protected[this] val pit: SeqSplitter[T], val otherpit: SeqSplitter[S])
588+
extends ParSeqLikeTransformer[Combiner[(U, S), That], ParSeqLikeZip[U, S, That]] {
589589
@volatile var result: Result = null
590590
def leaf(prev: Option[Result]) = result = pit.zip2combiner[U, S, That](otherpit, cf())
591591
protected[this] def newSubtask(p: SuperParIterator) = throw new UnsupportedOperationException
@@ -595,15 +595,15 @@ self =>
595595
val pits = pit.psplitWithSignalling(fp, sp)
596596
val opits = otherpit.psplitWithSignalling(fp, sp)
597597
Seq(
598-
new Zip(fp, cf, pits(0), opits(0)),
599-
new Zip(sp, cf, pits(1), opits(1))
598+
new ParSeqLikeZip(fp, cf, pits(0), opits(0)),
599+
new ParSeqLikeZip(sp, cf, pits(1), opits(1))
600600
)
601601
}
602-
override def merge(that: Zip[U, S, That]) = result = result combine that.result
602+
override def merge(that: ParSeqLikeZip[U, S, That]) = result = result combine that.result
603603
}
604604

605605
protected[this] class Corresponds[S](corr: (T, S) => Boolean, protected[this] val pit: SeqSplitter[T], val otherpit: SeqSplitter[S])
606-
extends Accessor[Boolean, Corresponds[S]] {
606+
extends ParSeqLikeAccessor[Boolean, Corresponds[S]] {
607607
@volatile var result: Boolean = true
608608
def leaf(prev: Option[Boolean]) = if (!pit.isAborted) {
609609
result = pit.corresponds(corr)(otherpit)

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -563,24 +563,24 @@ self =>
563563

564564
/* iterator transformers */
565565

566-
class Taken(tk: Int) extends super.Taken(tk) with SeqSplitter[T] {
566+
class RemainsIteratorTaken(tk: Int) extends Taken(tk) with SeqSplitter[T] {
567567
override def dup = super.dup.asInstanceOf[SeqSplitter[T]]
568568
override def split: Seq[SeqSplitter[T]] = super.split.asInstanceOf[Seq[SeqSplitter[T]]]
569569
def psplit(sizes: Int*): Seq[SeqSplitter[T]] = takeSeq(self.psplit(sizes: _*)) { (p, n) => p.take(n) }
570570
}
571-
override private[collection] def newTaken(until: Int): Taken = new Taken(until)
571+
override private[collection] def newTaken(until: Int): RemainsIteratorTaken = new RemainsIteratorTaken(until)
572572
override def take(n: Int): SeqSplitter[T] = newTaken(n)
573573
override def slice(from1: Int, until1: Int): SeqSplitter[T] = newSliceInternal(newTaken(until1), from1)
574574

575-
class Mapped[S](f: T => S) extends super.Mapped[S](f) with SeqSplitter[S] {
575+
class RemainsIteratorMapped[S](f: T => S) extends Mapped[S](f) with SeqSplitter[S] {
576576
override def dup = super.dup.asInstanceOf[SeqSplitter[S]]
577577
override def split: Seq[SeqSplitter[S]] = super.split.asInstanceOf[Seq[SeqSplitter[S]]]
578578
def psplit(sizes: Int*): Seq[SeqSplitter[S]] = self.psplit(sizes: _*).map { _ map f }
579579
}
580580

581-
override def map[S](f: T => S) = new Mapped(f)
581+
override def map[S](f: T => S) = new RemainsIteratorMapped(f)
582582

583-
class Appended[U >: T, PI <: SeqSplitter[U]](it: PI) extends super.Appended[U, PI](it) with SeqSplitter[U] {
583+
class RemainsIteratorAppended[U >: T, PI <: SeqSplitter[U]](it: PI) extends Appended[U, PI](it) with SeqSplitter[U] {
584584
override def dup = super.dup.asInstanceOf[SeqSplitter[U]]
585585
override def split: Seq[SeqSplitter[U]] = super.split.asInstanceOf[Seq[SeqSplitter[U]]]
586586
def psplit(sizes: Int*): Seq[SeqSplitter[U]] = if (firstNonEmpty) {
@@ -609,17 +609,17 @@ self =>
609609
} else curr.asInstanceOf[SeqSplitter[U]].psplit(sizes: _*)
610610
}
611611

612-
def appendParSeq[U >: T, PI <: SeqSplitter[U]](that: PI) = new Appended[U, PI](that)
612+
def appendParSeq[U >: T, PI <: SeqSplitter[U]](that: PI) = new RemainsIteratorAppended[U, PI](that)
613613

614-
class Zipped[S](ti: SeqSplitter[S]) extends super.Zipped[S](ti) with SeqSplitter[(T, S)] {
614+
class RemainsIteratorZipped[S](ti: SeqSplitter[S]) extends Zipped[S](ti) with SeqSplitter[(T, S)] {
615615
override def dup = super.dup.asInstanceOf[SeqSplitter[(T, S)]]
616616
override def split: Seq[SeqSplitter[(T, S)]] = super.split.asInstanceOf[Seq[SeqSplitter[(T, S)]]]
617617
def psplit(szs: Int*) = (self.psplit(szs: _*) zip that.psplit(szs: _*)) map { p => p._1 zipParSeq p._2 }
618618
}
619619

620-
override def zipParSeq[S](that: SeqSplitter[S]) = new Zipped(that)
620+
override def zipParSeq[S](that: SeqSplitter[S]) = new RemainsIteratorZipped(that)
621621

622-
class ZippedAll[U >: T, S](ti: SeqSplitter[S], thise: U, thate: S) extends super.ZippedAll[U, S](ti, thise, thate) with SeqSplitter[(U, S)] {
622+
class RemainsIteratorZippedAll[U >: T, S](ti: SeqSplitter[S], thise: U, thate: S) extends ZippedAll[U, S](ti, thise, thate) with SeqSplitter[(U, S)] {
623623
override def dup = super.dup.asInstanceOf[SeqSplitter[(U, S)]]
624624
private def patchem = {
625625
val selfrem = self.remaining
@@ -640,7 +640,7 @@ self =>
640640
}
641641
}
642642

643-
override def zipAllParSeq[S, U >: T, R >: S](that: SeqSplitter[S], thisElem: U, thatElem: R) = new ZippedAll[U, R](that, thisElem, thatElem)
643+
override def zipAllParSeq[S, U >: T, R >: S](that: SeqSplitter[S], thisElem: U, thatElem: R) = new RemainsIteratorZippedAll[U, R](that, thisElem, thatElem)
644644

645645
def reverse: SeqSplitter[T] = {
646646
val pa = mutable.ParArray.fromIterables(self).reverse

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,11 @@ trait Tasks {
139139
*/
140140
trait AdaptiveWorkStealingTasks extends Tasks {
141141

142-
trait WrappedTask[R, Tp] extends super.WrappedTask[R, Tp] {
143-
@volatile var next: WrappedTask[R, Tp] = null
142+
trait AWSTWrappedTask[R, Tp] extends WrappedTask[R, Tp] {
143+
@volatile var next: AWSTWrappedTask[R, Tp] = null
144144
@volatile var shouldWaitFor = true
145145

146-
def split: Seq[WrappedTask[R, Tp]]
146+
def split: Seq[AWSTWrappedTask[R, Tp]]
147147

148148
def compute() = if (body.shouldSplitFurther) {
149149
internal()
@@ -178,8 +178,8 @@ trait AdaptiveWorkStealingTasks extends Tasks {
178178
}
179179

180180
def spawnSubtasks() = {
181-
var last: WrappedTask[R, Tp] = null
182-
var head: WrappedTask[R, Tp] = this
181+
var last: AWSTWrappedTask[R, Tp] = null
182+
var head: AWSTWrappedTask[R, Tp] = this
183183
do {
184184
val subtasks = head.split
185185
head = subtasks.head
@@ -237,14 +237,14 @@ trait HavingForkJoinPool {
237237
*/
238238
trait ForkJoinTasks extends Tasks with HavingForkJoinPool {
239239

240-
trait WrappedTask[R, +Tp] extends RecursiveAction with super.WrappedTask[R, Tp] {
240+
trait FJTWrappedTask[R, +Tp] extends RecursiveAction with WrappedTask[R, Tp] {
241241
def start() = fork
242242
def sync() = join
243243
def tryCancel() = tryUnfork
244244
}
245245

246246
// specialize ctor
247-
protected def newWrappedTask[R, Tp](b: Task[R, Tp]): WrappedTask[R, Tp]
247+
protected def newWrappedTask[R, Tp](b: Task[R, Tp]): FJTWrappedTask[R, Tp]
248248

249249
/** The fork/join pool of this collection.
250250
*/
@@ -300,12 +300,12 @@ object ForkJoinTasks {
300300
*/
301301
trait AdaptiveWorkStealingForkJoinTasks extends ForkJoinTasks with AdaptiveWorkStealingTasks {
302302

303-
class WrappedTask[R, Tp](val body: Task[R, Tp])
304-
extends super[ForkJoinTasks].WrappedTask[R, Tp] with super[AdaptiveWorkStealingTasks].WrappedTask[R, Tp] {
303+
class AWSFJTWrappedTask[R, Tp](val body: Task[R, Tp])
304+
extends FJTWrappedTask[R, Tp] with AWSTWrappedTask[R, Tp] {
305305
def split = body.split.map(b => newWrappedTask(b))
306306
}
307307

308-
def newWrappedTask[R, Tp](b: Task[R, Tp]) = new WrappedTask[R, Tp](b)
308+
def newWrappedTask[R, Tp](b: Task[R, Tp]) = new AWSFJTWrappedTask[R, Tp](b)
309309
}
310310

311311
/** An implementation of the `Tasks` that uses Scala `Future`s to compute

core/src/main/scala/scala/collection/parallel/mutable/ParArray.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ self =>
590590
val targarrseq = ArraySeq.make(targetarr).asInstanceOf[ArraySeq[S]]
591591

592592
// fill it in parallel
593-
tasksupport.executeAndWaitResult(new Map[S](f, targetarr, 0, length))
593+
tasksupport.executeAndWaitResult(new ParArrayMap[S](f, targetarr, 0, length))
594594

595595
// wrap it into a parallel array
596596
new ParArray[S](targarrseq)
@@ -652,7 +652,7 @@ self =>
652652
}
653653
}
654654

655-
class Map[S](f: T => S, targetarr: Array[Any], offset: Int, howmany: Int) extends Task[Unit, Map[S]] {
655+
class ParArrayMap[S](f: T => S, targetarr: Array[Any], offset: Int, howmany: Int) extends Task[Unit, ParArrayMap[S]] {
656656
var result = ()
657657

658658
def leaf(prev: Option[Unit]) = {
@@ -667,7 +667,7 @@ self =>
667667
}
668668
def split = {
669669
val fp = howmany / 2
670-
List(new Map(f, targetarr, offset, fp), new Map(f, targetarr, offset + fp, howmany - fp))
670+
List(new ParArrayMap(f, targetarr, offset, fp), new ParArrayMap(f, targetarr, offset + fp, howmany - fp))
671671
}
672672
def shouldSplitFurther = howmany > scala.collection.parallel.thresholdFromSize(length, tasksupport.parallelismLevel)
673673
}

0 commit comments

Comments
 (0)