You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2023/03/18 10:59:18 UTC

[incubator-pekko] branch main updated: Add mapValues for Scala 2.12 collection compat

This is an automated email from the ASF dual-hosted git repository.

hepin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new 33583e027b Add mapValues for Scala 2.12 collection compat
33583e027b is described below

commit 33583e027b67ffb355c0f707f419d8def6783bb6
Author: Matthew de Detrich <ma...@aiven.io>
AuthorDate: Fri Mar 17 20:49:57 2023 +0100

    Add mapValues for Scala 2.12 collection compat
---
 .../scala-2.12/org/apache/pekko/util/ccompat/package.scala   | 12 +++++++++++-
 .../src/main/scala/org/apache/pekko/Plugin.scala             |  9 +++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/actor/src/main/scala-2.12/org/apache/pekko/util/ccompat/package.scala b/actor/src/main/scala-2.12/org/apache/pekko/util/ccompat/package.scala
index 94d03cbe11..823814d60e 100644
--- a/actor/src/main/scala-2.12/org/apache/pekko/util/ccompat/package.scala
+++ b/actor/src/main/scala-2.12/org/apache/pekko/util/ccompat/package.scala
@@ -14,7 +14,7 @@
 package org.apache.pekko.util
 
 import scala.{ collection => c }
-import scala.collection.{ immutable => i, mutable => m, GenTraversable }
+import scala.collection.{ immutable => i, mutable => m, GenTraversable, IterableView }
 import scala.collection.generic.{ CanBuildFrom, GenericCompanion, Sorted, SortedSetFactory }
 import scala.language.higherKinds
 import scala.language.implicitConversions
@@ -88,6 +88,10 @@ package object ccompat {
   type IterableOnce[+X] = c.TraversableOnce[X]
   val IterableOnce = c.TraversableOnce
 
+  implicit def toMapViewExtensionMethods[K, V, C <: scala.collection.Map[K, V]](
+      self: IterableView[(K, V), C]): MapViewExtensionMethods[K, V, C] =
+    new MapViewExtensionMethods[K, V, C](self)
+
   implicit class ImmutableSortedSetOps[A](val real: i.SortedSet[A]) extends AnyVal {
     def unsorted: i.Set[A] = real
   }
@@ -101,3 +105,9 @@ package object ccompat {
 class TraversableOnceExtensionMethods[A](private val self: c.TraversableOnce[A]) extends AnyVal {
   def iterator: Iterator[A] = self.toIterator
 }
+
+class MapViewExtensionMethods[K, V, C <: scala.collection.Map[K, V]](
+    private val self: IterableView[(K, V), C]) extends AnyVal {
+  def mapValues[W, That](f: V => W)(implicit bf: CanBuildFrom[IterableView[(K, V), C], (K, W), That]): That =
+    self.map[(K, W), That] { case (k, v) => (k, f(v)) }
+}
diff --git a/plugins/serialversion-remover-plugin/src/main/scala/org/apache/pekko/Plugin.scala b/plugins/serialversion-remover-plugin/src/main/scala/org/apache/pekko/Plugin.scala
index 961b5734fe..3e9a684a49 100644
--- a/plugins/serialversion-remover-plugin/src/main/scala/org/apache/pekko/Plugin.scala
+++ b/plugins/serialversion-remover-plugin/src/main/scala/org/apache/pekko/Plugin.scala
@@ -1,3 +1,12 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * license agreements; and to You under the Apache License, version 2.0:
+ *
+ *   https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * This file is part of the Apache Pekko project, derived from Akka.
+ */
+
 /*
  * Copyright (C) 2021-2022 Lightbend Inc. <https://www.lightbend.com>
  */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org