From 9a6a3a74340ffeebdd871e6993c52efb61e1832b 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 86e6762be..907574188 100644 --- a/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala +++ b/internal/zinc-testing/src/main/scala/xsbti/TestCallback.scala @@ -175,11 +175,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.view.mapValues(_.toSet).toMap.withDefaultValue(Set.empty)