Skip to content

Update to Scala 2.13.0-RC1 #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jdk:
- openjdk11

scala:
- 2.13.0-M4
- 2.13.0-RC1

script:
- sbt ++$TRAVIS_SCALA_VERSION test
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO Make it a cross project including Scala.js

scalaVersion := "2.13.0-M4"
scalaVersion := "2.13.0-RC1"

organization := "org.scala-lang"

Expand Down
43 changes: 20 additions & 23 deletions src/main/scala/scala/collection/MultiDict.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package scala.collection

import annotation.unchecked.uncheckedVariance
import scala.util.hashing.MurmurHash3

/**
Expand All @@ -14,10 +13,11 @@ trait MultiDict[K, V]
with MultiDictOps[K, V, MultiDict, MultiDict[K, V]]
with Equals {

def multiMapFactory: MapFactory[MultiDictCC] = MultiDict

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

def canEqual(that: Any): Boolean = true

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

protected[this] type MultiDictCC[K, V] = CC[K, V] @uncheckedVariance

def multiMapFactory: MapFactory[MultiDictCC]
def multiDictFactory: MapFactory[CC]

protected[this] def multiMapFromIterable[L, W](it: Iterable[(L, W)]): CC[L, W] =
multiMapFactory.from(it)
protected def multiDictFromIterable[L, W](it: Iterable[(L, W)]): CC[L, W] =
multiDictFactory.from(it)

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

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

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

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

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

/** Concatenate the entries given in `that` iterable to `this` multidict */
def concat(that: Iterable[(K, V)]): C =
fromSpecificIterable(new View.Concat(toIterable, that))

override def withFilter(p: ((K, V)) => Boolean): MultiDictOps.WithFilter[K, V, IterableCC, CC] =
new MultiDictOps.WithFilter(this, p)
def concat(that: IterableOnce[(K, V)]): C = fromSpecific(that match {
case that: collection.Iterable[(K, V)] => new View.Concat(toIterable, that)
case _ => iterator ++ that.iterator
})

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

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

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

override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, CC] =
new WithFilter[K, V, IterableCC, CC](`this`, (kv: (K, V)) => p(kv) && q(kv))
Expand Down
15 changes: 11 additions & 4 deletions src/main/scala/scala/collection/MultiSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ trait MultiSet[A]
with MultiSetOps[A, MultiSet, MultiSet[A]]
with Equals {

override def iterableFactory: IterableFactory[MultiSet] = MultiSet
override protected def fromSpecific(coll: IterableOnce[A]): MultiSet[A] = iterableFactory.from(coll)
override protected def newSpecificBuilder: mutable.Builder[A, MultiSet[A]] = iterableFactory.newBuilder
override def empty: MultiSet[A] = iterableFactory.empty

def canEqual(that: Any): Boolean = true

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

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

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

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

/**
* @return a new multiset summing the occurrences of this multiset
Expand Down
23 changes: 10 additions & 13 deletions src/main/scala/scala/collection/SortedMultiDict.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package scala.collection

import annotation.unchecked.uncheckedVariance

/**
* A multidict whose keys are sorted
* @tparam K the type of keys
Expand All @@ -13,19 +11,21 @@ trait SortedMultiDict[K, V]

def unsorted: MultiDict[K, V] = this

override protected[this] def fromSpecificIterable(coll: Iterable[(K, V)]): SortedMultiDictCC[K, V] = sortedMultiMapFactory.from(coll)
override protected[this] def newSpecificBuilder: mutable.Builder[(K, V), SortedMultiDictCC[K, V]] = sortedMultiMapFactory.newBuilder[K, V]
def sortedMultiDictFactory: SortedMapFactory[SortedMultiDict] = SortedMultiDict
override protected def fromSpecific(coll: IterableOnce[(K, V)]): SortedMultiDict[K, V] = sortedMultiDictFactory.from(coll)
override protected def newSpecificBuilder: mutable.Builder[(K, V), SortedMultiDict[K, V]] = sortedMultiDictFactory.newBuilder
override def empty: SortedMultiDict[K, V] = sortedMultiDictFactory.empty
override def withFilter(p: ((K, V)) => Boolean): SortedMultiDictOps.WithFilter[K, V, Iterable, MultiDict, SortedMultiDict] = new SortedMultiDictOps.WithFilter(this, p)

}

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

protected[this] type SortedMultiDictCC[X, Y] = CC[X, Y] @uncheckedVariance
def sortedMultiDictFactory: SortedMapFactory[CC]

def sortedMultiMapFactory: SortedMapFactory[SortedMultiDictCC]

protected[this] def sortedFromIterable[L : Ordering, W](it: Iterable[(L, W)]): CC[L, W]
protected[this] def sortedFromIterable[L : Ordering, W](it: Iterable[(L, W)]): CC[L, W] = sortedMultiDictFactory.from(it)
protected[this] def sortedFromSets[L : Ordering, W](it: Iterable[(L, Set[W])]): CC[L, W] =
sortedFromIterable(it.view.flatMap { case (l, ws) => ws.map(w => (l, w)) })

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

override def withFilter(p: ((K, V)) => Boolean): SortedMultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC, CC] =
new SortedMultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC, CC](this, p)

/**
* @return a sorted multidict that contains all the entries of `this` sorted multidict,
* transformed by the function `f`
Expand Down Expand Up @@ -134,10 +131,10 @@ object SortedMultiDictOps {
) extends MultiDictOps.WithFilter[K, V, IterableCC, MultiDictCC](`this`, p) {

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

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

override def withFilter(q: ((K, V)) => Boolean): WithFilter[K, V, IterableCC, MultiDictCC, CC] =
new WithFilter[K, V, IterableCC, MultiDictCC, CC](`this`, kv => p(kv) && q(kv))
Expand Down
23 changes: 9 additions & 14 deletions src/main/scala/scala/collection/SortedMultiSet.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,22 @@ trait SortedMultiSet[A]

def unsorted: MultiSet[A] = this

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

protected[this] def sortedFromIterable[B : Ordering](it: scala.collection.Iterable[B]): SortedIterableCC[B] = sortedIterableFactory.from(it)

def sortedIterableFactory: SortedIterableFactory[SortedIterableCC] = SortedMultiSet
}

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

protected[this] type SortedIterableCC[X] = CC[X] @uncheckedVariance

def sortedIterableFactory: SortedIterableFactory[SortedIterableCC]
def sortedIterableFactory: SortedIterableFactory[CC]

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

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

override def withFilter(p: A => Boolean): SortedMultiSetOps.WithFilter[A, IterableCC, CC] =
new SortedMultiSetOps.WithFilter(this, p)

/** Builds a new sorted multiset by applying a function to all elements of this sorted multiset.
*
* @param f the function to apply to each element.
Expand Down Expand Up @@ -165,7 +160,7 @@ object SortedMultiSetOps {
class WithFilter[A, +IterableCC[_], +CC[X] <: MultiSet[X]](
`this`: SortedMultiSetOps[A, CC, _] with IterableOps[A, IterableCC, _],
p: A => Boolean
) extends IterableOps.WithFilter(`this`, p) {
) extends IterableOps.WithFilter[A, IterableCC](`this`, p) {

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

This file was deleted.

44 changes: 0 additions & 44 deletions src/main/scala/scala/collection/decorators/HasIterableOps.scala

This file was deleted.

Loading