Skip to content

Commit 1a46759

Browse files
authored
Merge pull request #15 from scala/remove-extensibility-framework
Update to Scala 2.13.0-RC1
2 parents 0bff1f2 + 8186d04 commit 1a46759

26 files changed

+127
-433
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jdk:
55
- openjdk11
66

77
scala:
8-
- 2.13.0-M4
8+
- 2.13.0-RC1
99

1010
script:
1111
- sbt ++$TRAVIS_SCALA_VERSION test

build.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// TODO Make it a cross project including Scala.js
22

3-
scalaVersion := "2.13.0-M4"
3+
scalaVersion := "2.13.0-RC1"
44

55
organization := "org.scala-lang"
66

src/main/scala/scala/collection/MultiDict.scala

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package scala.collection
22

3-
import annotation.unchecked.uncheckedVariance
43
import scala.util.hashing.MurmurHash3
54

65
/**
@@ -14,10 +13,11 @@ trait MultiDict[K, V]
1413
with MultiDictOps[K, V, MultiDict, MultiDict[K, V]]
1514
with Equals {
1615

17-
def multiMapFactory: MapFactory[MultiDictCC] = MultiDict
18-
19-
override protected[this] def fromSpecificIterable(coll: Iterable[(K, V)]): MultiDictCC[K, V] = multiMapFactory.from(coll)
20-
override protected[this] def newSpecificBuilder: mutable.Builder[(K, V), MultiDictCC[K, V]] = multiMapFactory.newBuilder[K, V]
16+
def multiDictFactory: MapFactory[MultiDict] = MultiDict
17+
override protected def fromSpecific(coll: IterableOnce[(K, V)]): MultiDict[K, V] = multiDictFactory.from(coll)
18+
override protected def newSpecificBuilder: mutable.Builder[(K, V), MultiDict[K, V]] = multiDictFactory.newBuilder
19+
override def empty: MultiDict[K, V] = multiDictFactory.empty
20+
override def withFilter(p: ((K, V)) => Boolean): MultiDictOps.WithFilter[K, V, Iterable, MultiDict] = new MultiDictOps.WithFilter(this, p)
2121

2222
def canEqual(that: Any): Boolean = true
2323

@@ -43,18 +43,16 @@ trait MultiDict[K, V]
4343
trait MultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K, V]]
4444
extends IterableOps[(K, V), Iterable, C] {
4545

46-
protected[this] type MultiDictCC[K, V] = CC[K, V] @uncheckedVariance
47-
48-
def multiMapFactory: MapFactory[MultiDictCC]
46+
def multiDictFactory: MapFactory[CC]
4947

50-
protected[this] def multiMapFromIterable[L, W](it: Iterable[(L, W)]): CC[L, W] =
51-
multiMapFactory.from(it)
48+
protected def multiDictFromIterable[L, W](it: Iterable[(L, W)]): CC[L, W] =
49+
multiDictFactory.from(it)
5250

53-
protected[this] def fromSpecificSets(it: Iterable[(K, Set[V])]): C =
54-
fromSpecificIterable(it.view.flatMap { case (k, vs) => vs.view.map(v => (k, v)) })
51+
protected def fromSpecificSets(it: Iterable[(K, Set[V])]): C =
52+
fromSpecific(it.view.flatMap { case (k, vs) => vs.view.map(v => (k, v)) })
5553

56-
protected[this] def fromSets[L, W](it: Iterable[(L, Set[W])]): CC[L, W] =
57-
multiMapFromIterable(it.view.flatMap { case (k, vs) => vs.view.map(v => (k, v)) })
54+
protected def fromSets[L, W](it: Iterable[(L, Set[W])]): CC[L, W] =
55+
multiDictFromIterable(it.view.flatMap { case (k, vs) => vs.view.map(v => (k, v)) })
5856

5957
/**
6058
* @return All the elements contained in this multidict, grouped by key
@@ -104,7 +102,7 @@ trait MultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K, V]]
104102
* @tparam W new type of values
105103
*/
106104
def map[L, W](f: ((K, V)) => (L, W)): CC[L, W] =
107-
multiMapFromIterable(new View.Map(toIterable, f))
105+
multiDictFromIterable(new View.Map(toIterable, f))
108106

109107
/**
110108
* @return a multidict that contains all the entries of `this` multidict,
@@ -115,7 +113,7 @@ trait MultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K, V]]
115113
* @tparam W new type of values
116114
*/
117115
def flatMap[L, W](f: ((K, V)) => IterableOnce[(L, W)]): CC[L, W] =
118-
multiMapFromIterable(new View.FlatMap(toIterable, f))
116+
multiDictFromIterable(new View.FlatMap(toIterable, f))
119117

120118
/**
121119
* @return a multidict that contains all the entries of `this` multidict
@@ -133,11 +131,10 @@ trait MultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K, V]]
133131
)
134132

135133
/** Concatenate the entries given in `that` iterable to `this` multidict */
136-
def concat(that: Iterable[(K, V)]): C =
137-
fromSpecificIterable(new View.Concat(toIterable, that))
138-
139-
override def withFilter(p: ((K, V)) => Boolean): MultiDictOps.WithFilter[K, V, IterableCC, CC] =
140-
new MultiDictOps.WithFilter(this, p)
134+
def concat(that: IterableOnce[(K, V)]): C = fromSpecific(that match {
135+
case that: collection.Iterable[(K, V)] => new View.Concat(toIterable, that)
136+
case _ => iterator ++ that.iterator
137+
})
141138

142139
/**
143140
* @return Whether there exists a value associated with the given `key`
@@ -209,10 +206,10 @@ object MultiDictOps {
209206
) extends IterableOps.WithFilter[(K, V), IterableCC](`this`, p) {
210207

211208
def map[L, W](f: ((K, V)) => (L, W)): CC[L, W] =
212-
`this`.multiMapFactory.from(new View.Map(filtered, f))
209+
`this`.multiDictFactory.from(new View.Map(filtered, f))
213210

214211
def flatMap[L, W](f: ((K, V)) => IterableOnce[(L, W)]): CC[L, W] =
215-
`this`.multiMapFactory.from(new View.FlatMap(filtered, f))
212+
`this`.multiDictFactory.from(new View.FlatMap(filtered, f))
216213

217214
override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, CC] =
218215
new WithFilter[K, V, IterableCC, CC](`this`, (kv: (K, V)) => p(kv) && q(kv))

src/main/scala/scala/collection/MultiSet.scala

+11-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ trait MultiSet[A]
1212
with MultiSetOps[A, MultiSet, MultiSet[A]]
1313
with Equals {
1414

15+
override def iterableFactory: IterableFactory[MultiSet] = MultiSet
16+
override protected def fromSpecific(coll: IterableOnce[A]): MultiSet[A] = iterableFactory.from(coll)
17+
override protected def newSpecificBuilder: mutable.Builder[A, MultiSet[A]] = iterableFactory.newBuilder
18+
override def empty: MultiSet[A] = iterableFactory.empty
19+
1520
def canEqual(that: Any): Boolean = true
1621

1722
override def equals(o: Any): Boolean = o match {
@@ -36,11 +41,11 @@ trait MultiSetOps[A, +CC[X] <: MultiSet[X], +C <: MultiSet[A]]
3641
extends IterableOps[A, CC, C] {
3742

3843
protected[this] def fromSpecificOccurrences(it: Iterable[(A, Int)]): C =
39-
fromSpecificIterable(it.view.flatMap { case (e, n) => new View.Fill(n)(e) })
44+
fromSpecific(it.view.flatMap { case (e, n) => new View.Fill(n)(e) })
4045

4146
protected[this] def fromOccurrences[E](it: Iterable[(E, Int)]): CC[E] =
4247
// Note new MultiSet(it.to(Map)) would be more efficient but would also loose duplicates
43-
fromIterable(it.view.flatMap { case (e, n) => new View.Fill(n)(e) })
48+
iterableFactory.from(it.view.flatMap { case (e, n) => new View.Fill(n)(e) })
4449

4550
/**
4651
* @return All the elements contained in this multiset and their number of occurrences
@@ -68,8 +73,10 @@ trait MultiSetOps[A, +CC[X] <: MultiSet[X], +C <: MultiSet[A]]
6873
*
6974
* @param that the collection of elements to add to this multiset
7075
*/
71-
def concat(that: Iterable[A]): C =
72-
fromSpecificIterable(new View.Concat(toIterable, that))
76+
def concat(that: IterableOnce[A]): C = fromSpecific(that match {
77+
case that: collection.Iterable[A] => new View.Concat(this, that)
78+
case _ => iterator.concat(that.iterator)
79+
})
7380

7481
/**
7582
* @return a new multiset summing the occurrences of this multiset

src/main/scala/scala/collection/SortedMultiDict.scala

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package scala.collection
22

3-
import annotation.unchecked.uncheckedVariance
4-
53
/**
64
* A multidict whose keys are sorted
75
* @tparam K the type of keys
@@ -13,19 +11,21 @@ trait SortedMultiDict[K, V]
1311

1412
def unsorted: MultiDict[K, V] = this
1513

16-
override protected[this] def fromSpecificIterable(coll: Iterable[(K, V)]): SortedMultiDictCC[K, V] = sortedMultiMapFactory.from(coll)
17-
override protected[this] def newSpecificBuilder: mutable.Builder[(K, V), SortedMultiDictCC[K, V]] = sortedMultiMapFactory.newBuilder[K, V]
14+
def sortedMultiDictFactory: SortedMapFactory[SortedMultiDict] = SortedMultiDict
15+
override protected def fromSpecific(coll: IterableOnce[(K, V)]): SortedMultiDict[K, V] = sortedMultiDictFactory.from(coll)
16+
override protected def newSpecificBuilder: mutable.Builder[(K, V), SortedMultiDict[K, V]] = sortedMultiDictFactory.newBuilder
17+
override def empty: SortedMultiDict[K, V] = sortedMultiDictFactory.empty
18+
override def withFilter(p: ((K, V)) => Boolean): SortedMultiDictOps.WithFilter[K, V, Iterable, MultiDict, SortedMultiDict] = new SortedMultiDictOps.WithFilter(this, p)
19+
1820
}
1921

2022
trait SortedMultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K, V]]
2123
extends MultiDictOps[K, V, MultiDict, C]
2224
with SortedOps[K, C] {
2325

24-
protected[this] type SortedMultiDictCC[X, Y] = CC[X, Y] @uncheckedVariance
26+
def sortedMultiDictFactory: SortedMapFactory[CC]
2527

26-
def sortedMultiMapFactory: SortedMapFactory[SortedMultiDictCC]
27-
28-
protected[this] def sortedFromIterable[L : Ordering, W](it: Iterable[(L, W)]): CC[L, W]
28+
protected[this] def sortedFromIterable[L : Ordering, W](it: Iterable[(L, W)]): CC[L, W] = sortedMultiDictFactory.from(it)
2929
protected[this] def sortedFromSets[L : Ordering, W](it: Iterable[(L, Set[W])]): CC[L, W] =
3030
sortedFromIterable(it.view.flatMap { case (l, ws) => ws.map(w => (l, w)) })
3131

@@ -52,9 +52,6 @@ trait SortedMultiDictOps[K, V, +CC[X, Y] <: MultiDict[X, Y], +C <: MultiDict[K,
5252
rangeUntil(next)
5353
}
5454

55-
override def withFilter(p: ((K, V)) => Boolean): SortedMultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC, CC] =
56-
new SortedMultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC, CC](this, p)
57-
5855
/**
5956
* @return a sorted multidict that contains all the entries of `this` sorted multidict,
6057
* transformed by the function `f`
@@ -134,10 +131,10 @@ object SortedMultiDictOps {
134131
) extends MultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC](`this`, p) {
135132

136133
def map[L : Ordering, W](f: ((K, V)) => (L, W)): CC[L, W] =
137-
`this`.sortedMultiMapFactory.from(new View.Map(filtered, f))
134+
`this`.sortedMultiDictFactory.from(new View.Map(filtered, f))
138135

139136
def flatMap[L : Ordering, W](f: ((K, V)) => IterableOnce[(L, W)]): CC[L, W] =
140-
`this`.sortedMultiMapFactory.from(new View.FlatMap(filtered, f))
137+
`this`.sortedMultiDictFactory.from(new View.FlatMap(filtered, f))
141138

142139
override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, MultiDictCC, CC] =
143140
new WithFilter[K, V, IterableCC, MultiDictCC, CC](`this`, kv => p(kv) && q(kv))

src/main/scala/scala/collection/SortedMultiSet.scala

+9-14
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,22 @@ trait SortedMultiSet[A]
1212

1313
def unsorted: MultiSet[A] = this
1414

15-
override protected[this] def fromSpecificIterable(coll: Iterable[A]): SortedIterableCC[A] = sortedIterableFactory.from(coll)
16-
override protected[this] def newSpecificBuilder: mutable.Builder[A, SortedIterableCC[A]] = sortedIterableFactory.newBuilder[A]
15+
def sortedIterableFactory: SortedIterableFactory[SortedMultiSet] = SortedMultiSet
16+
override protected def fromSpecific(coll: IterableOnce[A]): SortedMultiSet[A] = sortedIterableFactory.from(coll)
17+
override protected def newSpecificBuilder: mutable.Builder[A, SortedMultiSet[A]] = sortedIterableFactory.newBuilder
18+
override def empty: SortedMultiSet[A] = sortedIterableFactory.empty
19+
override def withFilter(p: A => Boolean): SortedMultiSetOps.WithFilter[A, MultiSet, SortedMultiSet] = new SortedMultiSetOps.WithFilter(this, p)
1720

18-
protected[this] def sortedFromIterable[B : Ordering](it: scala.collection.Iterable[B]): SortedIterableCC[B] = sortedIterableFactory.from(it)
19-
20-
def sortedIterableFactory: SortedIterableFactory[SortedIterableCC] = SortedMultiSet
2121
}
2222

2323
trait SortedMultiSetOps[A, +CC[X] <: MultiSet[X], +C <: MultiSet[A]]
2424
extends MultiSetOps[A, MultiSet, C]
2525
with SortedOps[A, C] {
2626

27-
protected[this] type SortedIterableCC[X] = CC[X] @uncheckedVariance
28-
29-
def sortedIterableFactory: SortedIterableFactory[SortedIterableCC]
27+
def sortedIterableFactory: SortedIterableFactory[CC]
3028

31-
protected[this] def sortedFromIterable[B : Ordering](it: Iterable[B]): SortedIterableCC[B]
32-
protected[this] def sortedFromOccurrences[B : Ordering](it: Iterable[(B, Int)]): CC[B] =
29+
protected def sortedFromIterable[B : Ordering](it: Iterable[B]): CC[B] = sortedIterableFactory.from(it)
30+
protected def sortedFromOccurrences[B : Ordering](it: Iterable[(B, Int)]): CC[B] =
3331
sortedFromIterable(it.view.flatMap { case (b, n) => new View.Fill(n)(b) })
3432

3533
/** `this` sorted multiset upcasted to an unsorted multiset */
@@ -62,9 +60,6 @@ trait SortedMultiSetOps[A, +CC[X] <: MultiSet[X], +C <: MultiSet[A]]
6260
rangeUntil(next)
6361
}
6462

65-
override def withFilter(p: A => Boolean): SortedMultiSetOps.WithFilter[A, IterableCC, CC] =
66-
new SortedMultiSetOps.WithFilter(this, p)
67-
6863
/** Builds a new sorted multiset by applying a function to all elements of this sorted multiset.
6964
*
7065
* @param f the function to apply to each element.
@@ -165,7 +160,7 @@ object SortedMultiSetOps {
165160
class WithFilter[A, +IterableCC[_], +CC[X] <: MultiSet[X]](
166161
`this`: SortedMultiSetOps[A, CC, _] with IterableOps[A, IterableCC, _],
167162
p: A => Boolean
168-
) extends IterableOps.WithFilter(`this`, p) {
163+
) extends IterableOps.WithFilter[A, IterableCC](`this`, p) {
169164

170165
def map[B : Ordering](f: A => B): CC[B] =
171166
`this`.sortedIterableFactory.from(new View.Map(filtered, f))

src/main/scala/scala/collection/decorators/HasImmutableMapOps.scala

-43
This file was deleted.

src/main/scala/scala/collection/decorators/HasIterableOps.scala

-44
This file was deleted.

0 commit comments

Comments
 (0)