Skip to content

Commit e40c95e

Browse files
authored
Merge pull request scala#7696 from smarter/fix/dotty-compilation
Fix compilation of the collections with Dotty
2 parents 2ecd647 + 376f4c2 commit e40c95e

File tree

9 files changed

+24
-15
lines changed

9 files changed

+24
-15
lines changed

src/library/scala/collection/BitSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ trait BitSetOps[+C <: BitSet with BitSetOps[C]]
233233
coll.fromBitMaskNoCopy(a)
234234
}
235235

236-
override def concat(other: collection.IterableOnce[Int]): C = other match {
236+
override def concat(other: collection.IterableOnce[Int])(implicit dummy: DummyImplicit): C = other match {
237237
case otherBitset: BitSet =>
238238
val len = coll.nwords max otherBitset.nwords
239239
val words = new Array[Long](len)

src/library/scala/collection/Set.scala

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
176176
@deprecated("Use &- with an explicit collection argument instead of - with varargs", "2.13.0")
177177
def - (elem1: A, elem2: A, elems: A*): C = diff(elems.toSet + elem1 + elem2)
178178

179+
// The implicit dummy parameter is necessary to avoid erased signature clashes
180+
// between this `concat` and the polymorphic one defined in `IterableOps`.
181+
// Note that these clashes only happen in Dotty because it adds mixin
182+
// forwarders before erasure unlike Scala 2.
179183
/** Creates a new $coll by adding all elements contained in another collection to this $coll, omitting duplicates.
180184
*
181185
* This method takes a collection of elements and adds all elements, omitting duplicates, into $coll.
@@ -189,7 +193,7 @@ trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
189193
* @param that the collection containing the elements to add.
190194
* @return a new $coll with the given elements added, omitting duplicates.
191195
*/
192-
def concat(that: collection.IterableOnce[A]): C = fromSpecific(that match {
196+
def concat(that: collection.IterableOnce[A])(implicit dummy: DummyImplicit): C = fromSpecific(that match {
193197
case that: collection.Iterable[A] => new View.Concat(toIterable, that)
194198
case _ => iterator.concat(that.iterator)
195199
})
@@ -201,7 +205,7 @@ trait SetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
201205
def + (elem1: A, elem2: A, elems: A*): C = fromSpecific(new View.Concat(new View.Appended(new View.Appended(toIterable, elem1), elem2), elems))
202206

203207
/** Alias for `concat` */
204-
@`inline` final def ++ (that: collection.Iterable[A]): C = concat(that)
208+
@`inline` final def ++ (that: collection.IterableOnce[A])(implicit dummy: DummyImplicit): C = concat(that)
205209

206210
/** Computes the union between of set and another set.
207211
*

src/library/scala/collection/StrictOptimizedSetOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ trait StrictOptimizedSetOps[A, +CC[_], +C <: SetOps[A, CC, C]]
2323
extends SetOps[A, CC, C]
2424
with StrictOptimizedIterableOps[A, CC, C] {
2525

26-
override def concat(that: IterableOnce[A]): C =
26+
override def concat(that: IterableOnce[A])(implicit dummy: DummyImplicit): C =
2727
strictOptimizedConcat(that, newSpecificBuilder)
2828

2929
}

src/library/scala/collection/immutable/HashSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ final class HashSet[A] private[immutable] (val rootNode: SetNode[A])
7373
if (rootNode ne newRootNode) new HashSet(newRootNode) else this
7474
}
7575

76-
override def concat(that: IterableOnce[A]): HashSet[A] = {
76+
override def concat(that: IterableOnce[A])(implicit dummy: DummyImplicit): HashSet[A] = {
7777
val builder = iterableFactory.newBuilder[A]
7878
builder ++= this
7979
builder ++= that

src/library/scala/collection/immutable/Set.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ trait StrictOptimizedSetOps[A, +CC[X], +C <: SetOps[A, CC, C]]
7979
with collection.StrictOptimizedSetOps[A, CC, C]
8080
with StrictOptimizedIterableOps[A, CC, C] {
8181

82-
override def concat(that: collection.IterableOnce[A]): C = {
82+
override def concat(that: collection.IterableOnce[A])(implicit dummy: DummyImplicit): C = {
8383
var result: C = coll
8484
val it = that.iterator
8585
while (it.hasNext) result = result + it.next()

src/library/scala/collection/immutable/SortedSet.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ trait SortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
3838
def unsorted: Set[A]
3939
}
4040

41+
trait StrictOptimizedSortedSetOps[A, +CC[X] <: SortedSet[X], +C <: SortedSetOps[A, CC, C]]
42+
extends SortedSetOps[A, CC, C]
43+
with collection.StrictOptimizedSortedSetOps[A, CC, C]
44+
with StrictOptimizedSetOps[A, Set, C]
45+
4146
/**
4247
* $factoryInfo
4348
* @define coll immutable sorted set

src/library/scala/collection/immutable/TreeSeqMap.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ final class TreeSeqMap[K, +V] private (
284284
}
285285
object TreeSeqMap extends MapFactory[TreeSeqMap] {
286286
sealed trait OrderBy
287-
final object OrderBy {
288-
final case object Insertion extends OrderBy
289-
final case object Modification extends OrderBy
287+
object OrderBy {
288+
case object Insertion extends OrderBy
289+
case object Modification extends OrderBy
290290
}
291291

292292
val Empty = new TreeSeqMap[Nothing, Nothing](Ordering.empty, HashMap.empty, 0, OrderBy.Insertion)
@@ -351,7 +351,7 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] {
351351
private val Mapping = Map
352352

353353
/* The ordering implementation below is an adapted version of immutable.IntMap. */
354-
private[immutable] final object Ordering {
354+
private[immutable] object Ordering {
355355
import scala.collection.generic.BitOperations.Int._
356356

357357
@inline private[immutable] def toBinaryString(i: Int): String = s"$i/${i.toBinaryString}"
@@ -404,7 +404,7 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] {
404404
def empty[V]: Iterator[V] = Empty.asInstanceOf[Iterator[V]]
405405
}
406406

407-
final case object Zero extends Ordering[Nothing] {
407+
case object Zero extends Ordering[Nothing] {
408408
// Important! Without this equals method in place, an infinite
409409
// loop from Map.equals => size => pattern-match-on-Nil => equals
410410
// develops. Case objects and custom equality don't mix without
@@ -635,4 +635,4 @@ object TreeSeqMap extends MapFactory[TreeSeqMap] {
635635
else bin(prefix, mask, l, r)
636636
}
637637
}
638-
}
638+
}

src/library/scala/collection/immutable/TreeSet.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ final class TreeSet[A] private[immutable] (private[immutable] val tree: RB.Tree[
139139
def excl(elem: A): TreeSet[A] =
140140
newSetOrSelf(RB.delete(tree, elem))
141141

142-
override def concat(that: collection.IterableOnce[A]): TreeSet[A] = {
142+
override def concat(that: collection.IterableOnce[A])(implicit dummy: DummyImplicit): TreeSet[A] = {
143143
val t = that match {
144144
case ts: TreeSet[A] if ordering == ts.ordering =>
145145
RB.union(tree, ts.tree)

src/library/scala/sys/process/ProcessImpl.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private[process] trait ProcessImpl {
193193
protected[this] val source = new SyncVar[Option[InputStream]]
194194
override final def run(): Unit = {
195195
@tailrec def go(): Unit =
196-
source.take match {
196+
source.take() match {
197197
case Some(in) => runloop(in, pipe) ; go()
198198
case None =>
199199
}
@@ -216,7 +216,7 @@ private[process] trait ProcessImpl {
216216
protected[this] val sink = new SyncVar[Option[OutputStream]]
217217
override def run(): Unit = {
218218
@tailrec def go(): Unit =
219-
sink.take match {
219+
sink.take() match {
220220
case Some(out) => runloop(pipe, out) ; go()
221221
case None =>
222222
}

0 commit comments

Comments
 (0)