Skip to content

Commit 45c7724

Browse files
committed
Add HashMaps to stdlib
1 parent dfc4712 commit 45c7724

File tree

5 files changed

+1518
-5
lines changed

5 files changed

+1518
-5
lines changed

tests/pos-special/stdlib/collection/Seq.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
893893
* part of the result, but any following occurrences will.
894894
*/
895895
def diff[B >: A](that: Seq[B]): C = {
896-
val occ = occCounts(that)
896+
val occ = occCounts[B @uncheckedCaptures](that)
897897
fromSpecific(iterator.filter { x =>
898898
var include = false
899899
occ.updateWith(x) {
@@ -918,7 +918,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
918918
* in the result, but any following occurrences will be omitted.
919919
*/
920920
def intersect[B >: A](that: Seq[B]): C = {
921-
val occ = occCounts(that)
921+
val occ = occCounts[B @uncheckedCaptures](that)
922922
fromSpecific(iterator.filter { x =>
923923
var include = true
924924
occ.updateWith(x) {
@@ -966,7 +966,7 @@ trait SeqOps[+A, +CC[_], +C] extends Any with SeqViewOps[A, CC, C] { self =>
966966
iterableFactory.from(new View.Updated(this, index, elem))
967967
}
968968

969-
protected[collection] def occCounts[B](sq: Seq[B]): mutable.Map[B, Int] = {
969+
protected[collection] def occCounts[sealed B](sq: Seq[B]): mutable.Map[B, Int] = {
970970
val occ = new mutable.HashMap[B, Int]()
971971
for (y <- sq) occ.updateWith(y) {
972972
case None => Some(1)

tests/pos-special/stdlib/collection/StrictOptimizedSeqOps.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
package scala.collection
1414
import language.experimental.captureChecking
15+
import scala.annotation.unchecked.uncheckedCaptures
1516

1617
/**
1718
* Trait that overrides operations on sequences in order
@@ -79,7 +80,7 @@ trait StrictOptimizedSeqOps [+A, +CC[_], +C]
7980
override def diff[B >: A](that: Seq[B]): C =
8081
if (isEmpty || that.isEmpty) coll
8182
else {
82-
val occ = occCounts(that)
83+
val occ = occCounts[B @uncheckedCaptures](that)
8384
val b = newSpecificBuilder
8485
for (x <- this) {
8586
occ.updateWith(x) {
@@ -97,7 +98,7 @@ trait StrictOptimizedSeqOps [+A, +CC[_], +C]
9798
override def intersect[B >: A](that: Seq[B]): C =
9899
if (isEmpty || that.isEmpty) empty
99100
else {
100-
val occ = occCounts(that)
101+
val occ = occCounts[B @uncheckedCaptures](that)
101102
val b = newSpecificBuilder
102103
for (x <- this) {
103104
occ.updateWith(x) {

0 commit comments

Comments
 (0)