如何避免在从两个不同的地图创建合并地图时获得可序列化的产品类型

How to avoid getting the type Product With Serializable while creating a Merged maps from two different maps

我正在尝试合并下面两张地图。

var mutMap1: Map[String, List[CaseClass1]] = Map.empty[String, List[CaseClass1]]

var mutMap2: Map[String, List[CaseClass2]] = Map.empty[String, List[CaseClass2]]
var mergedMap = (mutMap1.keySet ++ mutMap2.keySet) map { i => i -> (mutMap1.get(i).toList ::: mutMap2.get(i).toList) } toMap

mergedMap的类型是Map[String,List[List[Product with Serializable]]]

But i am expecting this: Map[String,List[List[CaseClass3]]]

其中CaseClass3如下

case class CaseClass3(
                         caseClass1: List[CaseClass1],
                         caseClass1: List[CaseClass2]
                       )

谁能告诉我如何指定类型以避免得到 Product with Serializable

尝试

val mergedMap: Map[String, CaseClass3] =
  (mutMap1.keySet ++ mutMap2.keySet).map { i => i -> CaseClass3(mutMap1.getOrElse(i, List()), mutMap2.getOrElse(i, List())) }.toMap