summaryrefslogtreecommitdiff
path: root/src/library/scala/collection/mutable/SetLike.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/library/scala/collection/mutable/SetLike.scala')
-rw-r--r--src/library/scala/collection/mutable/SetLike.scala4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/library/scala/collection/mutable/SetLike.scala b/src/library/scala/collection/mutable/SetLike.scala
index 073bc59f61..c7618fcf3c 100644
--- a/src/library/scala/collection/mutable/SetLike.scala
+++ b/src/library/scala/collection/mutable/SetLike.scala
@@ -121,7 +121,9 @@ trait SetLike[A, +This <: SetLike[A, This] with Set[A]]
* which `p` returns `true` are retained in the set; all others
* are removed.
*/
- def retain(p: A => Boolean): Unit = for (elem <- this.toList) if (!p(elem)) this -= elem
+ def retain(p: A => Boolean): Unit =
+ for (elem <- this.toList) // SI-7269 toList avoids ConcurrentModificationException
+ if (!p(elem)) this -= elem
/** Removes all elements from the set. After this operation is completed,
* the set will be empty.