From 71ec0275712d34ed6a07485ad983502e64e6f846 Mon Sep 17 00:00:00 2001 From: xuwei-k <6b656e6a69@gmail.com> Date: Sun, 6 Oct 2024 19:49:17 +0900 Subject: [PATCH] avoid deprecated collection.mutable.MultiMap --- .../src/main/scala/xsbti/TestCallback.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala b/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala index 484407c2f..8ccc840a7 100644 --- a/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala +++ b/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala @@ -181,11 +181,18 @@ object TestCallback { } private def pairsToMultiMap[A, B](pairs: Seq[(A, B)]): Map[A, Set[B]] = { - import scala.collection.mutable.{ HashMap, MultiMap } - val emptyMultiMap = new HashMap[A, scala.collection.mutable.Set[B]] with MultiMap[A, B] - val multiMap = pairs.foldLeft(emptyMultiMap) { - case (acc, (key, value)) => - acc.addBinding(key, value) + import scala.collection.mutable.HashMap + val multiMap = HashMap.empty[A, scala.collection.mutable.Set[B]] + pairs.foreach { + case (key, value) => + multiMap.get(key) match { + case None => + val set = collection.mutable.Set.empty[B] + set += value + multiMap(key) = set + case Some(set) => + set += value + } } // convert all collections to immutable variants multiMap.toMap.mapValues(_.toSet).toMap.withDefaultValue(Set.empty)