Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP building with 2.13.0-M4 #25267

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions akka-actor/src/main/scala-2.13/akka/compat/Future.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ import scala.collection.immutable
@InternalApi private[akka] object Future {
def fold[T, R](futures: TraversableOnce[SFuture[T]])(zero: R)(op: (R, T) ⇒ R)(implicit executor: ExecutionContext): SFuture[R] = {
// This will have performance implications since the elements are copied to a Vector
SFuture.foldLeft[T, R](futures.to[immutable.Iterable])(zero)(op)(executor)
SFuture.foldLeft[T, R](futures.to(immutable.Iterable))(zero)(op)(executor)
}

def fold[T, R](futures: immutable.Iterable[SFuture[T]])(zero: R)(op: (R, T) ⇒ R)(implicit executor: ExecutionContext): SFuture[R] =
SFuture.foldLeft[T, R](futures)(zero)(op)(executor)

def reduce[T, R >: T](futures: TraversableOnce[SFuture[T]])(op: (R, T) ⇒ R)(implicit executor: ExecutionContext): SFuture[R] = {
// This will have performance implications since the elements are copied to a Vector
SFuture.reduceLeft[T, R](futures.to[immutable.Iterable])(op)(executor)
SFuture.reduceLeft[T, R](futures.to(immutable.Iterable))(op)(executor)
}

def reduce[T, R >: T](futures: immutable.Iterable[SFuture[T]])(op: (R, T) ⇒ R)(implicit executor: ExecutionContext): SFuture[R] =
SFuture.reduceLeft[T, R](futures)(op)(executor)

def find[T](futures: TraversableOnce[SFuture[T]])(p: T ⇒ Boolean)(implicit executor: ExecutionContext): SFuture[Option[T]] = {
// This will have performance implications since the elements are copied to a Vector
SFuture.find[T](futures.to[immutable.Iterable])(p)(executor)
SFuture.find[T](futures.to(immutable.Iterable))(p)(executor)
}

def find[T](futures: immutable.Iterable[SFuture[T]])(p: T ⇒ Boolean)(implicit executor: ExecutionContext): SFuture[Option[T]] =
Expand Down
5 changes: 3 additions & 2 deletions akka-actor/src/main/scala/akka/actor/ActorSelection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.util.concurrent.CompletionStage
import scala.language.implicitConversions
import scala.annotation.tailrec
import scala.collection.immutable
import scala.collection.compat._
import scala.concurrent.Future
import scala.concurrent.Promise
import scala.concurrent.duration._
Expand Down Expand Up @@ -189,12 +190,12 @@ object ActorSelection {
* intention is to send messages frequently.
*/
def apply(anchorRef: ActorRef, elements: Iterable[String]): ActorSelection = {
val compiled: immutable.IndexedSeq[SelectionPathElement] = elements.collect({
val compiled: immutable.IndexedSeq[SelectionPathElement] = elements.iterator.collect({
case x if !x.isEmpty ⇒
if ((x.indexOf('?') != -1) || (x.indexOf('*') != -1)) SelectChildPattern(x)
else if (x == "..") SelectParent
else SelectChildName(x)
})(scala.collection.breakOut)
}).to(immutable.IndexedSeq)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't the trick to use elements.iterator to avoid creating the "heavy" intermediate collection?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. if it were 2.13-only code you could use .view, but .iterator is the cross-buildable solution

new ActorSelection with ScalaActorSelection {
override val anchor = anchorRef
override val path = compiled
Expand Down
4 changes: 2 additions & 2 deletions akka-actor/src/main/scala/akka/actor/Deployer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ private[akka] class Deployer(val settings: ActorSystem.Settings, val dynamicAcce
case (key, value: String) ⇒ (key → value)
}.toMap

config.root.asScala flatMap {
config.root.asScala.map {
case ("default", _) ⇒ None
case (key, value: ConfigObject) ⇒ parseConfig(key, value.toConfig)
case _ ⇒ None
} foreach deploy
}.flatten.foreach(deploy(_))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a regression in 2.13. The previous code should compile without changes.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def lookup(path: ActorPath): Option[Deploy] = lookup(path.elements.drop(1))

Expand Down
3 changes: 2 additions & 1 deletion akka-actor/src/main/scala/akka/actor/FaultHandling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import language.implicitConversions
import java.lang.{ Iterable ⇒ JIterable }
import java.util.concurrent.TimeUnit
import akka.japi.Util.immutableSeq
import scala.collection.compat._
import scala.collection.mutable.ArrayBuffer
import scala.collection.immutable
import scala.concurrent.duration.Duration
Expand Down Expand Up @@ -234,7 +235,7 @@ object SupervisorStrategy extends SupervisorStrategyLowPriorityImplicits {
case x ⇒ buf insert (x, ca)
}
buf
}.to[immutable.IndexedSeq]
}.to(immutable.IndexedSeq)

private[akka] def withinTimeRangeOption(withinTimeRange: Duration): Option[Duration] =
if (withinTimeRange.isFinite && withinTimeRange >= Duration.Zero) Some(withinTimeRange) else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ private[akka] object ChildrenContainer {
final case class Creation() extends SuspendReason with WaitingForChildren
case object Termination extends SuspendReason

class ChildRestartsIterable(stats: immutable.MapLike[_, ChildStats, _]) extends PartialImmutableValuesIterable[ChildStats, ChildRestartStats] {
class ChildRestartsIterable(stats: immutable.Map[String, ChildStats]) extends PartialImmutableValuesIterable[ChildStats, ChildRestartStats] {
override final def apply(c: ChildStats) = c.asInstanceOf[ChildRestartStats]
override final def isDefinedAt(c: ChildStats) = c.isInstanceOf[ChildRestartStats]
override final def valuesIterator = stats.valuesIterator
}

class ChildrenIterable(stats: immutable.MapLike[_, ChildStats, _]) extends PartialImmutableValuesIterable[ChildStats, ActorRef] {
class ChildrenIterable(stats: immutable.Map[String, ChildStats]) extends PartialImmutableValuesIterable[ChildStats, ActorRef] {
override final def apply(c: ChildStats) = c.asInstanceOf[ChildRestartStats].child
override final def isDefinedAt(c: ChildStats) = c.isInstanceOf[ChildRestartStats]
override final def valuesIterator = stats.valuesIterator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private[akka] trait DeathWatch { this: ActorCell ⇒
// when all actor references have uid, i.e. actorFor is removed
private def removeFromMap[T](subject: ActorRef, map: Map[ActorRef, T]): Map[ActorRef, T] =
if (subject.path.uid != ActorCell.undefinedUid) (map - subject) - new UndefinedUidActorRef(subject)
else map filterKeys (_.path != subject.path)
else map filter { case (key, _) ⇒ key.path != subject.path }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to use filterKeys followed by .toMap


private def updateWatching(ref: InternalActorRef, newMessage: Option[Any]): Unit =
watching = watching.updated(ref, newMessage)
Expand Down
11 changes: 6 additions & 5 deletions akka-actor/src/main/scala/akka/io/Dns.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import akka.actor._
import akka.routing.ConsistentHashingRouter.ConsistentHashable
import com.typesafe.config.Config

import scala.collection.{ breakOut, immutable }
import scala.collection.immutable
import scala.collection.compat._

abstract class Dns {
def cached(name: String): Option[Dns.Resolved] = None
Expand Down Expand Up @@ -41,12 +42,12 @@ object Dns extends ExtensionId[DnsExt] with ExtensionIdProvider {

object Resolved {
def apply(name: String, addresses: Iterable[InetAddress]): Resolved = {
val ipv4: immutable.Seq[Inet4Address] = addresses.collect({
val ipv4: immutable.Seq[Inet4Address] = addresses.iterator.collect({
case a: Inet4Address ⇒ a
})(breakOut)
val ipv6: immutable.Seq[Inet6Address] = addresses.collect({
}).to(immutable.Seq)
val ipv6: immutable.Seq[Inet6Address] = addresses.iterator.collect({
case a: Inet6Address ⇒ a
})(breakOut)
}).to(immutable.Seq)
Resolved(name, ipv4, ipv6)
}
}
Expand Down
1 change: 1 addition & 0 deletions akka-actor/src/main/scala/akka/io/Udp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package akka.io
import java.net.DatagramSocket
import java.net.InetSocketAddress
import com.typesafe.config.Config
import scala.collection.compat._
import scala.collection.immutable
import akka.io.Inet.{ SoJavaFactories, SocketOption }
import akka.util.Helpers.Requiring
Expand Down
3 changes: 2 additions & 1 deletion akka-actor/src/main/scala/akka/io/UdpConnected.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package akka.io

import java.lang.{ Iterable ⇒ JIterable }
import java.net.InetSocketAddress
import scala.collection.compat._
import scala.collection.immutable
import akka.io.Inet.SocketOption
import akka.io.Udp.UdpSettings
Expand Down Expand Up @@ -248,6 +249,6 @@ object UdpConnectedMessage {

implicit private def fromJava[T](coll: JIterable[T]): immutable.Traversable[T] = {
import scala.collection.JavaConverters._
coll.asScala.to[immutable.Traversable]
coll.asScala.to(immutable.Traversable)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private[akka] class RoutedActorCell(
case group: Group ⇒
val paths = group.paths(system)
if (paths.nonEmpty)
addRoutees(paths.map(p ⇒ group.routeeFor(p, this))(collection.breakOut))
addRoutees(paths.map(p ⇒ group.routeeFor(p, this)))
case _ ⇒
}
preSuperStart()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import akka.actor._
import akka.event.{ LogMarker, Logging, LoggingAdapter }
import java.util.concurrent.ConcurrentHashMap

import scala.collection.compat._
import scala.collection.mutable.ArrayBuffer
import java.io.NotSerializableException

Expand Down Expand Up @@ -400,7 +401,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
private val serializers: Map[String, Serializer] = {
val fromConfig = for ((k: String, v: String) ← settings.Serializers) yield k → serializerOf(v).get
val result = fromConfig ++ serializerDetails.map(d ⇒ d.alias → d.serializer)
ensureOnlyAllowedSerializers(result.map { case (_, ser) ⇒ ser }(collection.breakOut))
ensureOnlyAllowedSerializers(result.map { case (_, ser) ⇒ ser }.iterator)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest calling .iterator before calling .map

result
}

Expand All @@ -419,7 +420,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
}

val result = sort(fromConfig ++ fromSettings)
ensureOnlyAllowedSerializers(result.map { case (_, ser) ⇒ ser }(collection.breakOut))
ensureOnlyAllowedSerializers(result.map { case (_, ser) ⇒ ser }.iterator)
result
}

Expand Down Expand Up @@ -447,7 +448,7 @@ class Serialization(val system: ExtendedActorSystem) extends Extension {
case x ⇒ buf insert (x, ca)
}
buf
}).to[immutable.Seq]
}).to(immutable.Seq)

/**
* serializerMap is a Map whose keys is the class that is serializable and values is the serializer
Expand Down
11 changes: 6 additions & 5 deletions akka-actor/src/main/scala/akka/util/ByteIterator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import java.nio.{ ByteBuffer, ByteOrder }

import scala.annotation.tailrec
import scala.collection.LinearSeq
import scala.collection.compat._
import scala.collection.mutable.ListBuffer
import scala.reflect.ClassTag

Expand All @@ -33,7 +34,7 @@ object ByteIterator {
@inline final def head: Byte = array(from)

final def next(): Byte = {
if (!hasNext) Iterator.empty.next
if (!hasNext) Iterator.empty.next()
else { val i = from; from = from + 1; array(i) }
}

Expand Down Expand Up @@ -106,7 +107,7 @@ object ByteIterator {
if (n <= this.len) {
Array.copy(this.array, this.from, xs, offset, n)
this.drop(n)
} else Iterator.empty.next
} else Iterator.empty.next()
}

private def wrappedByteBuffer: ByteBuffer = ByteBuffer.wrap(array, from, len).asReadOnlyBuffer
Expand Down Expand Up @@ -229,7 +230,7 @@ object ByteIterator {
}

final override def clone: MultiByteArrayIterator = {
val clonedIterators: List[ByteArrayIterator] = iterators.map(_.clone)(collection.breakOut)
val clonedIterators: List[ByteArrayIterator] = iterators.iterator.map(_.clone).to(List)
new MultiByteArrayIterator(clonedIterators)
}

Expand Down Expand Up @@ -443,9 +444,9 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
if (found) index else -1
}

def indexOf(elem: Byte): Int = indexWhere { _ == elem }
def indexOf(elem: Byte): Int = indexWhere { (_: Byte) == elem }

override def indexOf[B >: Byte](elem: B): Int = indexWhere { _ == elem }
override def indexOf[B >: Byte](elem: B): Int = indexWhere { (_: Byte) == elem }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird that the explicit type was needed here, given the indexWhere is kind of obvious in what it accepts.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m fine with that. Being phased out anyway

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, more curious than a complaining.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def toByteString: ByteString

Expand Down
15 changes: 8 additions & 7 deletions akka-actor/src/main/scala/akka/util/ByteString.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import java.lang.{ Iterable ⇒ JIterable }

import scala.annotation.{ tailrec, varargs }
import scala.collection.IndexedSeqOptimized
import scala.collection.compat._
import scala.collection.mutable.{ Builder, WrappedArray }
import scala.collection.immutable
import scala.collection.immutable.{ IndexedSeq, VectorBuilder }
Expand Down Expand Up @@ -145,8 +146,8 @@ object ByteString {

implicit val canBuildFrom: CanBuildFrom[TraversableOnce[Byte], Byte, ByteString] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we don't need separate sources for 2.13 and 2.12- here?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you do :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new CanBuildFrom[TraversableOnce[Byte], Byte, ByteString] {
def apply(ignore: TraversableOnce[Byte]): ByteStringBuilder = newBuilder
def apply(): ByteStringBuilder = newBuilder
def apply(ignore: TraversableOnce[Byte]): ByteStringBuilder = new ByteStringBuilder
def apply(): ByteStringBuilder = new ByteStringBuilder
}

private[akka] object ByteString1C extends Companion {
Expand Down Expand Up @@ -844,7 +845,7 @@ object CompactByteString {
*/
def apply[T](bytes: T*)(implicit num: Integral[T]): CompactByteString = {
if (bytes.isEmpty) empty
else ByteString.ByteString1C(bytes.map(x ⇒ num.toInt(x).toByte)(collection.breakOut))
else ByteString.ByteString1C(bytes.iterator.map(x ⇒ num.toInt(x).toByte).to(Array))
}

/**
Expand Down Expand Up @@ -997,14 +998,14 @@ final class ByteStringBuilder extends Builder[Byte, ByteString] {
putByteArrayUnsafe(xs.array.clone)
case seq: collection.IndexedSeq[Byte] if shouldResizeTempFor(seq.length) ⇒
val copied = new Array[Byte](seq.length)
seq.copyToArray(copied)
xs.copyToArray(copied, 0)

clearTemp()
_builder += ByteString.ByteString1(copied)
_length += seq.length
case seq: collection.IndexedSeq[_] ⇒
ensureTempSize(_tempLength + xs.size)
xs.copyToArray(_temp, _tempLength)
case seq: collection.IndexedSeq[Byte] ⇒
ensureTempSize(_tempLength + seq.size)
seq.copyToArray(_temp, _tempLength)
_tempLength += seq.length
_length += seq.length
case _ ⇒
Expand Down
3 changes: 2 additions & 1 deletion akka-actor/src/main/scala/akka/util/SubclassifiedIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package akka.util

import scala.collection.immutable
import scala.collection.compat._

/**
* Typeclass which describes a classification hierarchy. Observe the contract between `isEqual` and `isSubclass`!
Expand Down Expand Up @@ -211,5 +212,5 @@ private[akka] class SubclassifiedIndex[K, V] private (protected var values: Set[
private def mergeChangesByKey(changes: Changes): Changes =
(emptyMergeMap[K, V] /: changes) {
case (m, (k, s)) ⇒ m.updated(k, m(k) ++ s)
}.to[immutable.Seq]
}.to(immutable.Seq)
}
6 changes: 3 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ resolverSettings

lazy val aggregatedProjects: Seq[ProjectReference] = Seq(
actor, actorTests,
agent,
//agent,
benchJmh,
camel,
cluster, clusterMetrics, clusterSharding, clusterTools,
contrib,
distributedData,
docs,
//docs,
multiNodeTestkit,
osgi,
persistence, persistenceQuery, persistenceShared, persistenceTck,
Expand Down Expand Up @@ -190,7 +190,7 @@ lazy val distributedData = akkaModule("akka-distributed-data")

lazy val docs = akkaModule("akka-docs")
.dependsOn(
actor, cluster, clusterMetrics, slf4j, agent, camel, osgi, persistenceTck, persistenceQuery, distributedData, stream,
actor, cluster, clusterMetrics, slf4j, /*agent,*/ camel, osgi, persistenceTck, persistenceQuery, distributedData, stream,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we will need to deal with agent some how, jut not release it for 2.13+?

clusterTools % "compile->compile;test->test",
clusterSharding % "compile->compile;test->test",
testkit % "compile->compile;test->test",
Expand Down
20 changes: 14 additions & 6 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@ object Dependencies {
lazy val scalaCheckVersion = settingKey[String]("The version of ScalaCheck to use.")
lazy val java8CompatVersion = settingKey[String]("The version of scala-java8-compat to use.")
val junitVersion = "4.12"
val sslConfigVersion = "0.2.3"
val sslConfigVersion = "0.2.4"
val slf4jVersion = "1.7.25"
val scalaXmlVersion = "1.0.6"
val aeronVersion = "1.9.1"

val Versions = Seq(
crossScalaVersions := Seq("2.11.12", "2.12.6"),
crossScalaVersions := Seq("2.13.0-M4"),
scalaVersion := System.getProperty("akka.build.scalaVersion", crossScalaVersions.value.head),
scalaStmVersion := sys.props.get("akka.build.scalaStmVersion").getOrElse("0.8"),
scalaCheckVersion := sys.props.get("akka.build.scalaCheckVersion").getOrElse(
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 12 ⇒ "1.13.5" // does not work for 2.11
case _ ⇒ "1.13.2"
case Some((2, n)) if n >= 12 ⇒ "1.14.0"
case _ ⇒ "1.13.2" // anything later does not work for 2.11
}),
scalaTestVersion := "3.0.4",
scalaTestVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 => "3.0.6-SNAP1"
case _ => "3.0.4"
}
},
java8CompatVersion := {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, n)) if n >= 13 ⇒ "0.9.0"
Expand Down Expand Up @@ -76,6 +81,9 @@ object Dependencies {

val aeronDriver = "io.aeron" % "aeron-driver" % aeronVersion // ApacheV2
val aeronClient = "io.aeron" % "aeron-client" % aeronVersion // ApacheV2

val collectionCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "0.1.1" // BSD New

object Docs {
val sprayJson = "io.spray" %% "spray-json" % "1.3.3" % "test"
val gson = "com.google.code.gson" % "gson" % "2.8.2" % "test"
Expand Down Expand Up @@ -132,7 +140,7 @@ object Dependencies {
// TODO check if `l ++=` everywhere expensive?
val l = libraryDependencies

val actor = l ++= Seq(config, java8Compat.value)
val actor = l ++= Seq(config, collectionCompat, java8Compat.value)

val testkit = l ++= Seq(Test.junit, Test.scalatest.value) ++ Test.metricsAll

Expand Down
1 change: 1 addition & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ addSbtPlugin("com.lightbend" % "sbt-whitesource" % "0.1.12")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.0") // for advanced PR validation features
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0") // for maintenance of copyright file header
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.6.0-M9")

// used for @unidoc directive
libraryDependencies += "io.github.lukehutch" % "fast-classpath-scanner" % "2.12.3"