@@ -15,6 +15,7 @@ package mutable
1515
1616import scala .collection .generic .DefaultSerializationProxy
1717import scala .math .Ordering
18+ import language .experimental .captureChecking
1819
1920/** A heap-based priority queue.
2021 *
@@ -66,7 +67,7 @@ import scala.math.Ordering
6667 * @define mayNotTerminateInf
6768 * @define willNotTerminateInf
6869 */
69- sealed class PriorityQueue [A ](implicit val ord : Ordering [A ])
70+ sealed class PriorityQueue [sealed A ](implicit val ord : Ordering [A ])
7071 extends AbstractIterable [A ]
7172 with Iterable [A ]
7273 with IterableOps [A , Iterable , PriorityQueue [A ]]
@@ -77,7 +78,7 @@ sealed class PriorityQueue[A](implicit val ord: Ordering[A])
7778 with Serializable
7879{
7980
80- private class ResizableArrayAccess [A0 ] extends ArrayBuffer [A0 ] {
81+ private class ResizableArrayAccess [sealed A0 ] extends ArrayBuffer [A0 ] {
8182 override def mapInPlace (f : A0 => A0 ): this .type = {
8283 var i = 1 // see "we do not use array(0)" comment below (???)
8384 val siz = this .size
@@ -106,7 +107,7 @@ sealed class PriorityQueue[A](implicit val ord: Ordering[A])
106107 override def isEmpty : Boolean = resarr.p_size0 < 2
107108
108109 // not eligible for EvidenceIterableFactoryDefaults since C != CC[A] (PriorityQueue[A] != Iterable[A])
109- override protected def fromSpecific (coll : scala.collection.IterableOnce [A ]): PriorityQueue [A ] = PriorityQueue .from(coll)
110+ override protected def fromSpecific (coll : scala.collection.IterableOnce [A ]^ ): PriorityQueue [A ] = PriorityQueue .from(coll)
110111 override protected def newSpecificBuilder : Builder [A , PriorityQueue [A ]] = PriorityQueue .newBuilder
111112 override def empty : PriorityQueue [A ] = PriorityQueue .empty
112113
@@ -161,7 +162,7 @@ sealed class PriorityQueue[A](implicit val ord: Ordering[A])
161162 this
162163 }
163164
164- override def addAll (xs : IterableOnce [A ]): this .type = {
165+ override def addAll (xs : IterableOnce [A ]^ ): this .type = {
165166 val from = resarr.p_size0
166167 for (x <- xs.iterator) unsafeAdd(x)
167168 heapify(from)
@@ -364,7 +365,7 @@ sealed class PriorityQueue[A](implicit val ord: Ordering[A])
364365 pq
365366 }
366367
367- override def copyToArray [B >: A ](xs : Array [B ], start : Int , len : Int ): Int = {
368+ override def copyToArray [sealed B >: A ](xs : Array [B ], start : Int , len : Int ): Int = {
368369 val copied = IterableOnce .elemsToCopyToArray(length, xs.length, start, len)
369370 if (copied > 0 ) {
370371 Array .copy(resarr.p_array, 1 , xs, start, copied)
@@ -383,7 +384,7 @@ sealed class PriorityQueue[A](implicit val ord: Ordering[A])
383384
384385@ SerialVersionUID (3L )
385386object PriorityQueue extends SortedIterableFactory [PriorityQueue ] {
386- def newBuilder [A : Ordering ]: Builder [A , PriorityQueue [A ]] = {
387+ def newBuilder [sealed A : Ordering ]: Builder [A , PriorityQueue [A ]] = {
387388 new Builder [A , PriorityQueue [A ]] {
388389 val pq = new PriorityQueue [A ]
389390 def addOne (elem : A ): this .type = { pq.unsafeAdd(elem); this }
@@ -392,9 +393,9 @@ object PriorityQueue extends SortedIterableFactory[PriorityQueue] {
392393 }
393394 }
394395
395- def empty [A : Ordering ]: PriorityQueue [A ] = new PriorityQueue [A ]
396+ def empty [sealed A : Ordering ]: PriorityQueue [A ] = new PriorityQueue [A ]
396397
397- def from [E : Ordering ](it : IterableOnce [E ]): PriorityQueue [E ] = {
398+ def from [sealed E : Ordering ](it : IterableOnce [E ]^ ): PriorityQueue [E ] = {
398399 val b = newBuilder[E ]
399400 b ++= it
400401 b.result()
0 commit comments