diff options
author | Paul Phillips <paulp@improving.org> | 2010-08-19 16:04:23 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-08-19 16:04:23 +0000 |
commit | d8fed0f583c05a109c0c0b2bd53687ee8ee1e153 (patch) | |
tree | 6b817d10a088ab19f67be8c688994d8516b4c8e6 | |
parent | 8bef04a234b9c9005504a6fcd3f4f3dd10973ff8 (diff) | |
download | scala-d8fed0f583c05a109c0c0b2bd53687ee8ee1e153.tar.gz scala-d8fed0f583c05a109c0c0b2bd53687ee8ee1e153.tar.bz2 scala-d8fed0f583c05a109c0c0b2bd53687ee8ee1e153.zip |
Discovered ListMap.++ returns a Map instead of ...
Discovered ListMap.++ returns a Map instead of a ListMap. Does
preserving binary compatibility mean we can't fix this sort of thing?
Fixing for now, inquiring via: review by odersky.
-rw-r--r-- | src/library/scala/collection/immutable/ListMap.scala | 8 | ||||
-rw-r--r-- | src/library/scala/collection/immutable/SortedMap.scala | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala index 6721d5bbf0..6a166e365d 100644 --- a/src/library/scala/collection/immutable/ListMap.scala +++ b/src/library/scala/collection/immutable/ListMap.scala @@ -89,6 +89,14 @@ class ListMap[A, +B] extends Map[A, B] with MapLike[A, B, ListMap[A, B]] { override def + [B1 >: B] (elem1: (A, B1), elem2: (A, B1), elems: (A, B1) *): ListMap[A, B1] = this + elem1 + elem2 ++ elems + /** Adds a number of elements provided by a traversable object + * and returns a new collection with the added elements. + * + * @param xs the traversable object. + */ + override def ++[B1 >: B](xs: TraversableOnce[(A, B1)]): ListMap[A, B1] = + ((repr: ListMap[A, B1]) /: xs) (_ + _) + /** This creates a new mapping without the given <code>key</code>. * If the map does not contain a mapping for the given key, the * method returns the same map. diff --git a/src/library/scala/collection/immutable/SortedMap.scala b/src/library/scala/collection/immutable/SortedMap.scala index 2f0749c37a..f49c4a9986 100644 --- a/src/library/scala/collection/immutable/SortedMap.scala +++ b/src/library/scala/collection/immutable/SortedMap.scala @@ -40,8 +40,7 @@ trait SortedMap[A, +B] extends Map[A, B] override def updated [B1 >: B](key: A, value: B1): SortedMap[A, B1] = this + ((key, value)) /** Add a key/value pair to this map. - * @param key the key - * @param value the value + * @param kv the key/value pair * @return A new map with the new binding added to this map * @note needs to be overridden in subclasses */ @@ -60,7 +59,7 @@ trait SortedMap[A, +B] extends Map[A, B] /** Adds a number of elements provided by a traversable object * and returns a new collection with the added elements. * - * @param elems the traversable object. + * @param xs the traversable object. */ override def ++[B1 >: B](xs: TraversableOnce[(A, B1)]): SortedMap[A, B1] = ((repr: SortedMap[A, B1]) /: xs) (_ + _) |