summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-02-11 11:07:20 -0800
committerJames Iry <jamesiry@gmail.com>2013-02-11 11:07:20 -0800
commit74fc185bcdc37f6a5362e499cb4adf42c18e89e6 (patch)
tree19820c7efd46e57f8ab7fe2330baec91f1db8c80 /src
parentb3b49d2217f21ce51eeed584f5bffb7febea5e50 (diff)
parent7b425bf7f02c15d6c3577f21318c6bdfc92d6b35 (diff)
downloadscala-74fc185bcdc37f6a5362e499cb4adf42c18e89e6.tar.gz
scala-74fc185bcdc37f6a5362e499cb4adf42c18e89e6.tar.bz2
scala-74fc185bcdc37f6a5362e499cb4adf42c18e89e6.zip
Merge pull request #2096 from ViniciusMiana/SI-6370
SI-6370 changed ListMap apply0 method to produce correct error message
Diffstat (limited to 'src')
-rw-r--r--src/library/scala/collection/immutable/ListMap.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/library/scala/collection/immutable/ListMap.scala b/src/library/scala/collection/immutable/ListMap.scala
index 670540187e..75817350e5 100644
--- a/src/library/scala/collection/immutable/ListMap.scala
+++ b/src/library/scala/collection/immutable/ListMap.scala
@@ -156,8 +156,12 @@ extends AbstractMap[A, B]
* @return the value associated with the given key.
*/
override def apply(k: A): B1 = apply0(this, k)
-
- @tailrec private def apply0(cur: ListMap[A, B1], k: A): B1 = if (k == cur.key) cur.value else apply0(cur.tail, k)
+
+
+ @tailrec private def apply0(cur: ListMap[A, B1], k: A): B1 =
+ if (cur.isEmpty) throw new NoSuchElementException("key not found: "+k)
+ else if (k == cur.key) cur.value
+ else apply0(cur.tail, k)
/** Checks if this map maps `key` to a value and return the
* value if it exists.