Skip to content

Commit a869a62

Browse files
committed
Avoid existentials in diff and intersect
to work around scala/bug#10920
1 parent eeea070 commit a869a62

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/library/scala/collection/ArrayOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,7 +1477,7 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
14771477
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will not form
14781478
* part of the result, but any following occurrences will.
14791479
*/
1480-
def diff(that: Seq[_ >: A]): Array[A] = mutable.ArraySeq.make(xs).diff(that).array.asInstanceOf[Array[A]]
1480+
def diff[B >: A](that: Seq[B]): Array[A] = mutable.ArraySeq.make(xs).diff(that).array.asInstanceOf[Array[A]]
14811481

14821482
/** Computes the multiset intersection between this array and another sequence.
14831483
*
@@ -1488,7 +1488,7 @@ final class ArrayOps[A](val xs: Array[A]) extends AnyVal {
14881488
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will be retained
14891489
* in the result, but any following occurrences will be omitted.
14901490
*/
1491-
def intersect(that: Seq[_ >: A]): Array[A] = mutable.ArraySeq.make(xs).intersect(that).array.asInstanceOf[Array[A]]
1491+
def intersect[B >: A](that: Seq[B]): Array[A] = mutable.ArraySeq.make(xs).intersect(that).array.asInstanceOf[Array[A]]
14921492

14931493
/** Groups elements in fixed size blocks by passing a "sliding window"
14941494
* over them (as opposed to partitioning them, as is done in grouped.)

src/library/scala/collection/Seq.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any
804804
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will not form
805805
* part of the result, but any following occurrences will.
806806
*/
807-
def diff(that: Seq[_ >: A]): C = {
807+
def diff[B >: A](that: Seq[B]): C = {
808808
val occ = occCounts(that)
809809
fromSpecific(iterator.filter { x =>
810810
val ox = occ(x) // Avoid multiple map lookups
@@ -825,7 +825,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any
825825
* ''n'' times in `that`, then the first ''n'' occurrences of `x` will be retained
826826
* in the result, but any following occurrences will be omitted.
827827
*/
828-
def intersect(that: Seq[_ >: A]): C = {
828+
def intersect[B >: A](that: Seq[B]): C = {
829829
val occ = occCounts(that)
830830
fromSpecific(iterator.filter { x =>
831831
val ox = occ(x) // Avoid multiple map lookups

src/library/scala/collection/StrictOptimizedSeqOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ trait StrictOptimizedSeqOps [+A, +CC[_], +C]
8080
b.result()
8181
}
8282

83-
override def diff(that: Seq[_ >: A]): C = {
83+
override def diff[B >: A](that: Seq[B]): C = {
8484
val occ = occCounts(that)
8585
val b = newSpecificBuilder
8686
for (x <- this) {
@@ -91,7 +91,7 @@ trait StrictOptimizedSeqOps [+A, +CC[_], +C]
9191
b.result()
9292
}
9393

94-
override def intersect(that: Seq[_ >: A]): C = {
94+
override def intersect[B >: A](that: Seq[B]): C = {
9595
val occ = occCounts(that)
9696
val b = newSpecificBuilder
9797
for (x <- this) {

src/library/scala/collection/StringOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ final class StringOps(private val s: String) extends AnyVal {
13461346
* part of the result, but any following occurrences will.
13471347
*/
13481348
@deprecated("Use `s.toSeq.diff(...).unwrap` instead of `s.diff(...)`", "2.13.0")
1349-
def diff(that: Seq[_ >: Char]): String = new WrappedString(s).diff(that).unwrap
1349+
def diff[B >: Char](that: Seq[B]): String = new WrappedString(s).diff(that).unwrap
13501350

13511351
/** Computes the multiset intersection between this string and another sequence.
13521352
*
@@ -1358,7 +1358,7 @@ final class StringOps(private val s: String) extends AnyVal {
13581358
* in the result, but any following occurrences will be omitted.
13591359
*/
13601360
@deprecated("Use `s.toSeq.intersect(...).unwrap` instead of `s.intersect(...)`", "2.13.0")
1361-
def intersect(that: Seq[_ >: Char]): String = new WrappedString(s).intersect(that).unwrap
1361+
def intersect[B >: Char](that: Seq[B]): String = new WrappedString(s).intersect(that).unwrap
13621362

13631363
/** Selects all distinct chars of this string ignoring the duplicates. */
13641364
@deprecated("Use `s.toSeq.distinct.unwrap` instead of `s.distinct`", "2.13.0")

src/library/scala/collection/immutable/LazyList.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,11 @@ final class LazyList[+A] private(private[this] var lazyState: () => LazyList.Sta
616616
if (isEmpty) tl
617617
else tail.reverseOnto(newLL(sCons(head, tl)))
618618

619-
override def diff(that: collection.Seq[_ >: A]): LazyList[A] =
619+
override def diff[B >: A](that: collection.Seq[B]): LazyList[A] =
620620
if (knownIsEmpty) LazyList.empty
621621
else super.diff(that)
622622

623-
override def intersect(that: collection.Seq[_ >: A]): LazyList[A] =
623+
override def intersect[B >: A](that: collection.Seq[B]): LazyList[A] =
624624
if (knownIsEmpty) LazyList.empty
625625
else super.intersect(that)
626626

0 commit comments

Comments
 (0)