summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/library/scala/collection/mutable/MultiMap.scala4
-rw-r--r--test/files/run/t2857.check1
-rw-r--r--test/files/run/t2857.scala9
3 files changed, 13 insertions, 1 deletions
diff --git a/src/library/scala/collection/mutable/MultiMap.scala b/src/library/scala/collection/mutable/MultiMap.scala
index 8279bd53f8..e335500349 100644
--- a/src/library/scala/collection/mutable/MultiMap.scala
+++ b/src/library/scala/collection/mutable/MultiMap.scala
@@ -40,7 +40,9 @@ trait MultiMap[A, B] extends Map[A, Set[B]] {
def removeBinding(key: A, value: B): this.type = {
get(key) match {
case None =>
- case Some(set) => set -= value
+ case Some(set) =>
+ set -= value
+ if (set.isEmpty) this -= key
}
this
}
diff --git a/test/files/run/t2857.check b/test/files/run/t2857.check
new file mode 100644
index 0000000000..c508d5366f
--- /dev/null
+++ b/test/files/run/t2857.check
@@ -0,0 +1 @@
+false
diff --git a/test/files/run/t2857.scala b/test/files/run/t2857.scala
new file mode 100644
index 0000000000..bd0d6fde16
--- /dev/null
+++ b/test/files/run/t2857.scala
@@ -0,0 +1,9 @@
+object Test extends Application {
+ import collection.mutable._
+ val m = new HashMap[Int, Set[String]] with MultiMap[Int, String]
+ m.addBinding(6, "Foo")
+ m.removeBinding(6, "Foo")
+ println(m.contains(6))
+}
+
+