From 7eaa94b0e7d312c7aac13775a4e234578d69ff2a Mon Sep 17 00:00:00 2001 From: Michel Davit Date: Thu, 5 Sep 2024 09:13:04 +0200 Subject: [PATCH] Set all classes final --- .../collection/compat/PackageShared.scala | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala b/compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala index 8d811e20..a27a68de 100644 --- a/compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala +++ b/compat/src/main/scala-2.11_2.12/scala/collection/compat/PackageShared.scala @@ -360,7 +360,7 @@ private[compat] trait PackageShared { new RandomExtensions(self) } -class ArrayExtensions(private val fact: Array.type) extends AnyVal { +final class ArrayExtensions(private val fact: Array.type) extends AnyVal { def from[A: ClassTag](source: TraversableOnce[A]): Array[A] = source match { case it: Iterable[A] => it.toArray[A] @@ -368,67 +368,67 @@ class ArrayExtensions(private val fact: Array.type) extends AnyVal { } } -class ImmutableSortedMapExtensions(private val fact: i.SortedMap.type) extends AnyVal { +final class ImmutableSortedMapExtensions(private val fact: i.SortedMap.type) extends AnyVal { def from[K: Ordering, V](source: TraversableOnce[(K, V)]): i.SortedMap[K, V] = build(i.SortedMap.newBuilder[K, V], source) } -class ImmutableListMapExtensions(private val fact: i.ListMap.type) extends AnyVal { +final class ImmutableListMapExtensions(private val fact: i.ListMap.type) extends AnyVal { def from[K, V](source: TraversableOnce[(K, V)]): i.ListMap[K, V] = build(i.ListMap.newBuilder[K, V], source) } -class ImmutableHashMapExtensions(private val fact: i.HashMap.type) extends AnyVal { +final class ImmutableHashMapExtensions(private val fact: i.HashMap.type) extends AnyVal { def from[K, V](source: TraversableOnce[(K, V)]): i.HashMap[K, V] = build(i.HashMap.newBuilder[K, V], source) } -class ImmutableTreeMapExtensions(private val fact: i.TreeMap.type) extends AnyVal { +final class ImmutableTreeMapExtensions(private val fact: i.TreeMap.type) extends AnyVal { def from[K: Ordering, V](source: TraversableOnce[(K, V)]): i.TreeMap[K, V] = build(i.TreeMap.newBuilder[K, V], source) } -class ImmutableIntMapExtensions(private val fact: i.IntMap.type) extends AnyVal { +final class ImmutableIntMapExtensions(private val fact: i.IntMap.type) extends AnyVal { def from[V](source: TraversableOnce[(Int, V)]): i.IntMap[V] = build(i.IntMap.canBuildFrom[Int, V](), source) } -class ImmutableLongMapExtensions(private val fact: i.LongMap.type) extends AnyVal { +final class ImmutableLongMapExtensions(private val fact: i.LongMap.type) extends AnyVal { def from[V](source: TraversableOnce[(Long, V)]): i.LongMap[V] = build(i.LongMap.canBuildFrom[Long, V](), source) } -class MutableLongMapExtensions(private val fact: m.LongMap.type) extends AnyVal { +final class MutableLongMapExtensions(private val fact: m.LongMap.type) extends AnyVal { def from[V](source: TraversableOnce[(Long, V)]): m.LongMap[V] = build(m.LongMap.canBuildFrom[Long, V](), source) } -class MutableHashMapExtensions(private val fact: m.HashMap.type) extends AnyVal { +final class MutableHashMapExtensions(private val fact: m.HashMap.type) extends AnyVal { def from[K, V](source: TraversableOnce[(K, V)]): m.HashMap[K, V] = build(m.HashMap.canBuildFrom[K, V](), source) } -class MutableListMapExtensions(private val fact: m.ListMap.type) extends AnyVal { +final class MutableListMapExtensions(private val fact: m.ListMap.type) extends AnyVal { def from[K, V](source: TraversableOnce[(K, V)]): m.ListMap[K, V] = build(m.ListMap.canBuildFrom[K, V](), source) } -class MutableMapExtensions(private val fact: m.Map.type) extends AnyVal { +final class MutableMapExtensions(private val fact: m.Map.type) extends AnyVal { def from[K, V](source: TraversableOnce[(K, V)]): m.Map[K, V] = build(m.Map.canBuildFrom[K, V](), source) } -class StreamExtensionMethods[A](private val stream: Stream[A]) extends AnyVal { +final class StreamExtensionMethods[A](private val stream: Stream[A]) extends AnyVal { def lazyAppendedAll(as: => TraversableOnce[A]): Stream[A] = stream.append(as) } -class SortedExtensionMethods[K, T <: Sorted[K, T]](private val fact: Sorted[K, T]) { +final class SortedExtensionMethods[K, T <: Sorted[K, T]](private val fact: Sorted[K, T]) { def rangeFrom(from: K): T = fact.from(from) def rangeTo(to: K): T = fact.to(to) def rangeUntil(until: K): T = fact.until(until) } -class SortedMapExtensionMethods[K, V]( +final class SortedMapExtensionMethods[K, V]( private val self: collection.SortedMap[K, V] ) extends AnyVal { @@ -437,7 +437,7 @@ class SortedMapExtensionMethods[K, V]( def maxBefore(key: K): Option[(K, V)] = self.until(key).lastOption } -class SortedSetExtensionMethods[A]( +final class SortedSetExtensionMethods[A]( private val self: collection.SortedSet[A] ) extends AnyVal { @@ -446,7 +446,7 @@ class SortedSetExtensionMethods[A]( def maxBefore(key: A): Option[A] = self.until(key).lastOption } -class IteratorExtensionMethods[A](private val self: c.Iterator[A]) extends AnyVal { +final class IteratorExtensionMethods[A](private val self: c.Iterator[A]) extends AnyVal { def sameElements[B >: A](that: c.TraversableOnce[B]): Boolean = { self.sameElements(that.iterator) } @@ -457,7 +457,7 @@ class IteratorExtensionMethods[A](private val self: c.Iterator[A]) extends AnyVa def tapEach[U](f: A => U): c.Iterator[A] = self.map(a => { f(a); a }) } -class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A]) extends AnyVal { +final class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A]) extends AnyVal { def iterator: Iterator[A] = self.toIterator def minOption[B >: A](implicit ord: Ordering[B]): Option[A] = { @@ -489,7 +489,7 @@ class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A]) } } -class TraversableExtensionMethods[A](private val self: c.Traversable[A]) extends AnyVal { +final class TraversableExtensionMethods[A](private val self: c.Traversable[A]) extends AnyVal { def iterableFactory: GenericCompanion[Traversable] = self.companion def sizeCompare(otherSize: Int): Int = SizeCompareImpl.sizeCompareInt(self)(otherSize) @@ -498,11 +498,11 @@ class TraversableExtensionMethods[A](private val self: c.Traversable[A]) extends } -class SeqExtensionMethods[A](private val self: c.Seq[A]) extends AnyVal { +final class SeqExtensionMethods[A](private val self: c.Seq[A]) extends AnyVal { def lengthIs: SizeCompareOps = new SizeCompareOps(self) } -class SizeCompareOps private[compat] (private val it: c.Traversable[_]) extends AnyVal { +final class SizeCompareOps private[compat] (private val it: c.Traversable[_]) extends AnyVal { import SizeCompareImpl._ /** Tests if the size of the collection is less than some value. */ @@ -564,7 +564,7 @@ private object SizeCompareImpl { } } -class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversableLike[A, Repr]) +final class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversableLike[A, Repr]) extends AnyVal { def tapEach[U](f: A => U)(implicit bf: CanBuildFrom[Repr, A, Repr]): Repr = self.map(a => { f(a); a }) @@ -624,7 +624,7 @@ class TraversableLikeExtensionMethods[A, Repr](private val self: c.GenTraversabl } } -class TrulyTraversableLikeExtensionMethods[El1, Repr1]( +final class TrulyTraversableLikeExtensionMethods[El1, Repr1]( private val self: TraversableLike[El1, Repr1]) extends AnyVal { @@ -633,7 +633,7 @@ class TrulyTraversableLikeExtensionMethods[El1, Repr1]( ): Tuple2Zipped[El1, Repr1, El2, Repr2] = new Tuple2Zipped((self, t2)) } -class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2]( +final class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2]( private val self: Tuple2Zipped[El1, Repr1, El2, Repr2]) { def lazyZip[El3, Repr3, T3](t3: T3)(implicit @@ -641,7 +641,7 @@ class Tuple2ZippedExtensionMethods[El1, Repr1, El2, Repr2]( new Tuple3Zipped((self.colls._1, self.colls._2, t3)) } -class MapExtensionMethods[K, V](private val self: scala.collection.Map[K, V]) extends AnyVal { +final class MapExtensionMethods[K, V](private val self: scala.collection.Map[K, V]) extends AnyVal { def foreachEntry[U](f: (K, V) => U): Unit = { self.foreach { case (k, v) => f(k, v) } @@ -649,7 +649,7 @@ class MapExtensionMethods[K, V](private val self: scala.collection.Map[K, V]) ex } -class ImmutableMapExtensionMethods[K, V](private val self: scala.collection.immutable.Map[K, V]) +final class ImmutableMapExtensionMethods[K, V](private val self: scala.collection.immutable.Map[K, V]) extends AnyVal { def updatedWith[V1 >: V](key: K)(remappingFunction: (Option[V]) => Option[V1]): Map[K, V1] = @@ -659,7 +659,7 @@ class ImmutableMapExtensionMethods[K, V](private val self: scala.collection.immu } } -class MutableMapExtensionMethods[K, V](private val self: scala.collection.mutable.Map[K, V]) +final class MutableMapExtensionMethods[K, V](private val self: scala.collection.mutable.Map[K, V]) extends AnyVal { def updateWith(key: K)(remappingFunction: (Option[V]) => Option[V]): Option[V] = { @@ -672,7 +672,7 @@ class MutableMapExtensionMethods[K, V](private val self: scala.collection.mutabl } } -class MapViewExtensionMethods[K, V, C <: scala.collection.Map[K, V]]( +final class MapViewExtensionMethods[K, V, C <: scala.collection.Map[K, V]]( private val self: IterableView[(K, V), C]) extends AnyVal { @@ -693,23 +693,23 @@ class MapViewExtensionMethods[K, V, C <: scala.collection.Map[K, V]]( self.filter { case (k, _) => p(k) } } -class ImmutableQueueExtensionMethods[A](private val self: i.Queue[A]) extends AnyVal { +final class ImmutableQueueExtensionMethods[A](private val self: i.Queue[A]) extends AnyVal { def enqueueAll[B >: A](iter: c.Iterable[B]): i.Queue[B] = self.enqueue(iter.to[i.Iterable]) } -class MutableQueueExtensionMethods[Element](private val self: m.Queue[Element]) extends AnyVal { +final class MutableQueueExtensionMethods[Element](private val self: m.Queue[Element]) extends AnyVal { def enqueueAll(iter: c.Iterable[Element]): Unit = self.enqueue(iter.toIndexedSeq: _*) } -class OptionCompanionExtensionMethods(private val fact: Option.type) extends AnyVal { +final class OptionCompanionExtensionMethods(private val fact: Option.type) extends AnyVal { def when[A](cond: Boolean)(a: => A): Option[A] = if (cond) Some(a) else None @inline def unless[A](cond: Boolean)(a: => A): Option[A] = when(!cond)(a) } -class GenericCompanionExtensionMethods[CC[X] <: GenTraversable[X]]( +final class GenericCompanionExtensionMethods[CC[X] <: GenTraversable[X]]( private val companion: GenericCompanion[CC]) extends AnyVal { def unfold[A, S](init: S)(f: S => Option[(A, S)])( implicit cbf: CanBuildFrom[CC[A], A, CC[A]]