From d8fed0f583c05a109c0c0b2bd53687ee8ee1e153 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 19 Aug 2010 16:04:23 +0000 Subject: 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. --- src/library/scala/collection/immutable/ListMap.scala | 8 ++++++++ src/library/scala/collection/immutable/SortedMap.scala | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src/library') 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 key. * 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) (_ + _) -- cgit v1.2.3