I have some code that used to work under Scala 2.12 but now fails under 2.13.
Essentially my calls look like so:
Controller -> Service -> Actor -> Repo
My controller looks like this:
complete {
dep.chunkService.getChunksWithSubtitlesByDistribution(id, chunkState).map(
_.right.map(
chunkMap => StatusResult(
Meta(OK),
chunkMap.extractChunkDtoList,
chunkMap.extractSubtitleDtoList)): ToResponseMarshallable)
}
And the error I get is:
scala.collection.MapView$MapValues cannot be cast to scala.collection.immutable.Map
It happens on this line of the controller:
chunkMap => StatusResult(
The service method that is called by the controller has the signature:
def getChunksWithSubtitlesByDistribution(distributionId: UUID, state: Option[ChunkState]):
Future[Either[DistributionNotFoundError, Map[Chunk, List[Subtitle]]]]
The service sets up an Actor that makes the call to the Repo like so:
sender ! chunkRepo.getChunksWithSubtitlesByDistribution(distributionId, state).right.map(_.mapValues(_.sortWith((a, b) => a.start < b.start) ) )
It is that value which will be returned by chunkService.getChunksWithSubtitlesByDistribution
chunkRepo.getChunksWithSubtitlesByDistribution
returns this:
result match {
case Nil => Left(DistributionNotFoundError(distributionId))
case rs =>
Right(
rs.flatten
.groupBy { case (c, s) => c }
.mapValues(pairs => pairs.map { case (c, ss) => ss }.flatten)
.toMap
)
}
Not sure where in the chain the "MapView" comes into play, or how to get it to convert to a "normal" map?