Skip to content

Commit 46c61df

Browse files
committed
Get rid of RedBlack.scala for a while.
As a work-around for various bugs let's get rid of RedBlack.scala completely until those are fixed. I'll recheck this patch once we merge in latest Scala trunk. Signed-off-by: Grzegorz Kossakowski <grzegorz.kossakowski@gmail.com>
1 parent 51e8906 commit 46c61df

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/* __ *\
2+
** ________ ___ / / ___ Scala API **
3+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5+
** /____/\___/_/ |_/____/_/ | | **
6+
** |/ **
7+
\* */
8+
9+
10+
11+
package scala.collection
12+
package immutable
13+
14+
import generic._
15+
import mutable.Builder
16+
import annotation.unchecked.uncheckedVariance
17+
import annotation.bridge
18+
19+
/** A map whose keys are sorted.
20+
*
21+
* @tparam A the type of the keys contained in this sorted map.
22+
* @tparam B the type of the values associated with the keys.
23+
*
24+
* @author Sean McDirmid
25+
* @author Martin Odersky
26+
* @version 2.8
27+
* @since 2.4
28+
* @define Coll immutable.SortedMap
29+
* @define coll immutable sorted map
30+
*/
31+
trait SortedMap[A, +B] extends Map[A, B]
32+
with scala.collection.SortedMap[A, B]
33+
with MapLike[A, B, SortedMap[A, B]]
34+
with SortedMapLike[A, B, SortedMap[A, B]] { self =>
35+
36+
override protected[this] def newBuilder : Builder[(A, B), SortedMap[A, B]] =
37+
SortedMap.newBuilder[A, B]
38+
39+
override def empty: SortedMap[A, B] = SortedMap.empty
40+
override def updated [B1 >: B](key: A, value: B1): SortedMap[A, B1] = this + ((key, value))
41+
override def keySet: immutable.SortedSet[A] = new DefaultKeySortedSet
42+
43+
protected class DefaultKeySortedSet extends super.DefaultKeySortedSet with immutable.SortedSet[A] {
44+
override def + (elem: A): SortedSet[A] =
45+
if (this(elem)) this
46+
else SortedSet[A]() ++ this + elem
47+
override def - (elem: A): SortedSet[A] =
48+
if (this(elem)) SortedSet[A]() ++ this - elem
49+
else this
50+
override def rangeImpl(from : Option[A], until : Option[A]) : SortedSet[A] = {
51+
val map = self.rangeImpl(from, until)
52+
new map.DefaultKeySortedSet
53+
}
54+
}
55+
56+
/** Add a key/value pair to this map.
57+
* @param kv the key/value pair
58+
* @return A new map with the new binding added to this map
59+
* @note needs to be overridden in subclasses
60+
*/
61+
def + [B1 >: B](kv: (A, B1)): SortedMap[A, B1] = throw new AbstractMethodError("SortedMap.+")
62+
63+
/** Adds two or more elements to this collection and returns
64+
* a new collection.
65+
*
66+
* @param elem1 the first element to add.
67+
* @param elem2 the second element to add.
68+
* @param elems the remaining elements to add.
69+
*/
70+
override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): SortedMap[A, B1] =
71+
this + elem1 + elem2 ++ elems
72+
73+
/** Adds a number of elements provided by a traversable object
74+
* and returns a new collection with the added elements.
75+
*
76+
* @param xs the traversable object.
77+
*/
78+
override def ++[B1 >: B](xs: GenTraversableOnce[(A, B1)]): SortedMap[A, B1] =
79+
((repr: SortedMap[A, B1]) /: xs.seq) (_ + _)
80+
81+
@bridge def ++[B1 >: B](xs: TraversableOnce[(A, B1)]): SortedMap[A, B1] = ++(xs: GenTraversableOnce[(A, B1)])
82+
}
83+
84+
/** $factoryInfo
85+
* @define Coll immutable.SortedMap
86+
* @define coll immutable sorted map
87+
*/
88+
object SortedMap extends ImmutableSortedMapFactory[SortedMap] {
89+
/** $sortedMapCanBuildFromInfo */
90+
implicit def canBuildFrom[A, B](implicit ord: Ordering[A]): CanBuildFrom[Coll, (A, B), SortedMap[A, B]] = new SortedMapCanBuildFrom[A, B]
91+
def empty[A, B](implicit ord: Ordering[A]): SortedMap[A, B] = sys.error("TreeMap is not supported due to bugs. We're working on a fix.")
92+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/* __ *\
2+
** ________ ___ / / ___ Scala API **
3+
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
4+
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
5+
** /____/\___/_/ |_/____/_/ | | **
6+
** |/ **
7+
\* */
8+
9+
10+
11+
package scala.collection
12+
package immutable
13+
14+
import generic._
15+
import mutable.Builder
16+
17+
/** A subtrait of `collection.SortedSet` which represents sorted sets
18+
* which cannot be mutated.
19+
*
20+
* @author Sean McDirmid
21+
* @author Martin Odersky
22+
* @version 2.8
23+
* @since 2.4
24+
* @define Coll immutable.SortedSet
25+
* @define coll immutable sorted set
26+
*/
27+
trait SortedSet[A] extends Set[A] with scala.collection.SortedSet[A] with SortedSetLike[A, SortedSet[A]] {
28+
/** Needs to be overridden in subclasses. */
29+
override def empty: SortedSet[A] = SortedSet.empty[A]
30+
}
31+
32+
/** $factoryInfo
33+
* @define Coll immutable.SortedSet
34+
* @define coll immutable sorted set
35+
*/
36+
object SortedSet extends ImmutableSortedSetFactory[SortedSet] {
37+
/** $sortedSetCanBuildFromInfo */
38+
implicit def canBuildFrom[A](implicit ord: Ordering[A]): CanBuildFrom[Coll, A, SortedSet[A]] = new SortedSetCanBuildFrom[A]
39+
def empty[A](implicit ord: Ordering[A]): SortedSet[A] = sys.error("TreeSet is not supported due to bugs. We're working on a fix.")
40+
}

src/jdk2ikvm/src/scala/tools/jdk2ikvm/JDK2IKVM.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ abstract class JDK2IKVM
9393
"scala/collection/generic/ParSetFactory.scala",
9494
"scala/collection/generic/CanCombineFrom.scala",
9595
"scala/collection/generic/HasNewCombiner.scala",
96+
//breaks GWT due to bugs in scala (broken signatures) and bugs in jribble backend (broken jribble output)
97+
//excluding it for now
98+
"scala/collection/immutable/RedBlack.scala",
99+
//TreeMap and TreeSet depend on RedBlack.scala
100+
"scala/collection/immutable/TreeMap.scala",
101+
"scala/collection/immutable/TreeSet.scala",
96102
//depends on threads
97103
"scala/collection/generic/Signalling.scala",
98104
//depends on scala.io

0 commit comments

Comments
 (0)