From 01501148d78209c722c10ed65f280fc388bb2602 Mon Sep 17 00:00:00 2001 From: "ohze.net" Date: Thu, 25 Jun 2020 14:47:31 +0700 Subject: [PATCH] dotty phase 3: Some required syntax changes (#29139) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bùi Việt Thành --- .../testkit/typed/scaladsl/ActorTestKit.scala | 2 +- .../typed/scaladsl/BehaviorTestKitSpec.scala | 4 +- .../akka/actor/SupervisorHierarchySpec.scala | 2 +- .../akka/actor/dispatch/ActorModelSpec.scala | 2 +- .../scala/akka/io/TcpConnectionSpec.scala | 2 +- .../akka/io/TcpIntegrationSpecSupport.scala | 2 +- .../test/scala/akka/util/ByteStringSpec.scala | 124 +++++++++--------- .../akka/actor/typed/ActorRefIgnoreSpec.scala | 2 +- .../typed/internal/ActorSystemSpec.scala | 2 +- .../receptionist/ReceptionistApiSpec.scala | 2 +- .../scala/docs/akka/typed/FSMDocSpec.scala | 2 +- .../actor/typed/internal/ExtensionsImpl.scala | 5 +- .../src/main/scala/akka/actor/ActorRef.scala | 4 +- .../scala/akka/dispatch/CachingConfig.scala | 1 + .../src/main/scala/akka/japi/JavaAPI.scala | 2 +- .../src/main/scala/akka/util/Index.scala | 4 +- .../akka/remote/testkit/LogRoleReplace.scala | 2 +- .../remote/PhiAccrualFailureDetector.scala | 2 +- .../akka/remote/artery/tcp/TlsTcpSpec.scala | 7 +- .../akka/event/slf4j/Slf4jLoggerSpec.scala | 2 +- .../scala/akka/testkit/WithLogCapturing.scala | 2 +- .../reporter/AkkaConsoleReporter.scala | 4 +- 22 files changed, 90 insertions(+), 91 deletions(-) diff --git a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala index 6c8009a534..4f01784112 100644 --- a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala +++ b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala @@ -253,7 +253,7 @@ final class ActorTestKit private[akka] ( */ def stop[T](ref: ActorRef[T], max: FiniteDuration = timeout.duration): Unit = try { - Await.result(internalTestKitGuardian.ask { x: ActorRef[ActorTestKitGuardian.Ack.type] => + Await.result(internalTestKitGuardian.ask { (x: ActorRef[ActorTestKitGuardian.Ack.type]) => ActorTestKitGuardian.StopActor(ref, x) }, max) } catch { diff --git a/akka-actor-testkit-typed/src/test/scala/akka/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala b/akka-actor-testkit-typed/src/test/scala/akka/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala index 21452dfe30..3e3471774a 100644 --- a/akka-actor-testkit-typed/src/test/scala/akka/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala +++ b/akka-actor-testkit-typed/src/test/scala/akka/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala @@ -70,12 +70,12 @@ object BehaviorTestKitSpec { context.stop(child) Behaviors.same case SpawnAdapter => - context.spawnMessageAdapter { r: Reproduce => + context.spawnMessageAdapter { (r: Reproduce) => SpawnAnonymous(r.times) } Behaviors.same case SpawnAdapterWithName(name) => - context.spawnMessageAdapter({ r: Reproduce => + context.spawnMessageAdapter({ (r: Reproduce) => SpawnAnonymous(r.times) }, name) Behaviors.same diff --git a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala index bd4e6954e0..c32410749f 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/SupervisorHierarchySpec.scala @@ -442,7 +442,7 @@ object SupervisorHierarchySpec { Ping(ref) case x => // fail one child - val pick = ((if (x >= 0.25) x - 0.25 else x) * 4 * activeChildren.size).toInt + val pick = ((if (x >= 0.25f) x - 0.25f else x) * 4 * activeChildren.size).toInt Fail(activeChildren(pick), if (x > 0.25) Restart else Resume) }) diff --git a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala index f05fd0fc1c..bff16a9b80 100644 --- a/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/actor/dispatch/ActorModelSpec.scala @@ -411,7 +411,7 @@ abstract class ActorModelSpec(config: String) extends AkkaSpec(config) with Defa "Teammates left: " + team.size + " stopLatch: " + stopLatch.getCount + " inhab:" + dispatcher.inhabitants) import akka.util.ccompat.JavaConverters._ - team.asScala.toList.sortBy(_.self.path).foreach { cell: ActorCell => + team.asScala.toList.sortBy(_.self.path).foreach { (cell: ActorCell) => System.err.println( " - " + cell.self.path + " " + cell.isTerminated + " " + cell.mailbox.currentStatus + " " + cell.mailbox.numberOfMessages + " " + cell.mailbox.systemDrain(SystemMessageList.LNil).size) diff --git a/akka-actor-tests/src/test/scala/akka/io/TcpConnectionSpec.scala b/akka-actor-tests/src/test/scala/akka/io/TcpConnectionSpec.scala index 9656208005..f6ea7a4a82 100644 --- a/akka-actor-tests/src/test/scala/akka/io/TcpConnectionSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/io/TcpConnectionSpec.scala @@ -944,7 +944,7 @@ class TcpConnectionSpec extends AkkaSpec(""" }) } - trait SmallRcvBuffer { _: LocalServerTest => + trait SmallRcvBuffer { this: LocalServerTest => override def setServerSocketOptions(): Unit = localServerChannel.socket.setReceiveBufferSize(1024) } diff --git a/akka-actor-tests/src/test/scala/akka/io/TcpIntegrationSpecSupport.scala b/akka-actor-tests/src/test/scala/akka/io/TcpIntegrationSpecSupport.scala index fd81dc99e5..6f4aca031e 100644 --- a/akka-actor-tests/src/test/scala/akka/io/TcpIntegrationSpecSupport.scala +++ b/akka-actor-tests/src/test/scala/akka/io/TcpIntegrationSpecSupport.scala @@ -16,7 +16,7 @@ import akka.io.Inet.SocketOption import akka.testkit.{ AkkaSpec, TestProbe } import akka.testkit.SocketUtil.temporaryServerAddress -trait TcpIntegrationSpecSupport { _: AkkaSpec => +trait TcpIntegrationSpecSupport { this: AkkaSpec => class TestSetup(shouldBindServer: Boolean = true, runClientInExtraSystem: Boolean = true) { val clientSystem = diff --git a/akka-actor-tests/src/test/scala/akka/util/ByteStringSpec.scala b/akka-actor-tests/src/test/scala/akka/util/ByteStringSpec.scala index c01f3d68a8..76a71afd22 100644 --- a/akka-actor-tests/src/test/scala/akka/util/ByteStringSpec.scala +++ b/akka-actor-tests/src/test/scala/akka/util/ByteStringSpec.scala @@ -749,7 +749,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "be equal to the original" when { "compacting" in { - check { xs: ByteString => + check { (xs: ByteString) => val ys = xs.compact; (xs == ys) && ys.isCompact } } @@ -785,19 +785,19 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "behave as expected" when { "created from and decoding to String" in { - check { s: String => + check { (s: String) => ByteString(s, "UTF-8").decodeString("UTF-8") == s } } "taking its own length" in { - check { b: ByteString => + check { (b: ByteString) => b.take(b.length) eq b } } "created from and decoding to Base64" in { - check { a: ByteString => + check { (a: ByteString) => val encoded = a.encodeBase64 encoded == ByteString(java.util.Base64.getEncoder.encode(a.toArray)) && encoded.decodeBase64 == a @@ -805,7 +805,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "compacting" in { - check { a: ByteString => + check { (a: ByteString) => val wasCompact = a.isCompact val b = a.compact ((!wasCompact) || (b eq a)) && @@ -848,7 +848,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling apply" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, i1, i2) => likeVector(xs) { seq => @@ -859,27 +859,27 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling head" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVector(a) { _.head } } } "calling tail" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVector(a) { _.tail } } } "calling last" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVector(a) { _.last } } } "calling init" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVector(a) { _.init } } } "calling length" in { - check { a: ByteString => + check { (a: ByteString) => likeVector(a) { _.length } } } @@ -919,25 +919,25 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling foreach" in { - check { a: ByteString => + check { (a: ByteString) => likeVector(a) { it => var acc = 0; it.foreach { acc += _ }; acc } } } "calling foldLeft" in { - check { a: ByteString => + check { (a: ByteString) => likeVector(a) { _.foldLeft(0) { _ + _ } } } } "calling toArray" in { - check { a: ByteString => + check { (a: ByteString) => likeVector(a) { _.toArray.toSeq } } } "calling slice" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVector(xs)({ @@ -948,7 +948,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling take and drop" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVector(xs)({ @@ -959,7 +959,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling grouped" in { - check { grouped: ByteStringGrouped => + check { (grouped: ByteStringGrouped) => likeVector(grouped.bs) { _.grouped(grouped.size).toIndexedSeq } @@ -967,7 +967,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling copyToArray" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVector(xs)({ it => @@ -995,7 +995,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "given all types of ByteString" in { - check { bs: ByteString => + check { (bs: ByteString) => testSer(bs) } } @@ -1020,27 +1020,27 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling head" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVecIt(a) { _.head } } } "calling next" in { - check { a: ByteString => + check { (a: ByteString) => a.isEmpty || likeVecIt(a) { _.next() } } } "calling hasNext" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a) { _.hasNext } } } "calling length" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a)(_.length, strict = false) } } "calling duplicate" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a)({ _.duplicate match { case (a, b) => (a.toSeq, b.toSeq) } }, strict = false) } } @@ -1075,30 +1075,30 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } } "calling toSeq" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a) { _.toSeq } } } "calling foreach" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a) { it => var acc = 0; it.foreach { acc += _ }; acc } } } "calling foldLeft" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a) { _.foldLeft(0) { _ + _ } } } } "calling toArray" in { - check { a: ByteString => + check { (a: ByteString) => likeVecIt(a) { _.toArray.toSeq } } } "calling slice" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVecIt(xs)({ @@ -1109,7 +1109,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling take and drop" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVecIt(xs)({ @@ -1120,7 +1120,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling copyToArray" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => slice match { case (xs, from, until) => likeVecIt(xs)({ it => @@ -1136,7 +1136,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "function as expected" when { "getting Bytes, using getByte and getBytes" in { // mixing getByte and getBytes here for more rigorous testing - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => val (bytes, from, to) = slice val input = bytes.iterator val output = new Array[Byte](bytes.length) @@ -1148,7 +1148,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "getting Bytes with a given length" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => val (bytes, _, _) = slice val input = bytes.iterator (input.getBytes(bytes.length).toSeq == bytes) && input.isEmpty @@ -1156,7 +1156,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "getting ByteString with a given length" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => val (bytes, _, _) = slice val input = bytes.iterator (input.getByteString(bytes.length) == bytes) && input.isEmpty @@ -1165,7 +1165,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "getting Bytes, using the InputStream wrapper" in { // combining skip and both read methods here for more rigorous testing - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => val (bytes, from, to) = slice val a = (0 max from) min bytes.length val b = (a max to) min bytes.length @@ -1192,7 +1192,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { } "calling copyToBuffer" in { - check { bytes: ByteString => + check { (bytes: ByteString) => import java.nio.ByteBuffer val buffer = ByteBuffer.allocate(bytes.size) bytes.copyToBuffer(buffer) @@ -1223,52 +1223,52 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "decode data correctly" when { "decoding Short in big-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testShortDecoding(slice, BIG_ENDIAN) } } "decoding Short in little-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testShortDecoding(slice, LITTLE_ENDIAN) } } "decoding Int in big-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testIntDecoding(slice, BIG_ENDIAN) } } "decoding Int in little-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testIntDecoding(slice, LITTLE_ENDIAN) } } "decoding Long in big-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testLongDecoding(slice, BIG_ENDIAN) } } "decoding Long in little-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testLongDecoding(slice, LITTLE_ENDIAN) } } "decoding Float in big-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testFloatDecoding(slice, BIG_ENDIAN) } } "decoding Float in little-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testFloatDecoding(slice, LITTLE_ENDIAN) } } "decoding Double in big-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testDoubleDecoding(slice, BIG_ENDIAN) } } "decoding Double in little-endian" in { - check { slice: ByteStringSlice => + check { (slice: ByteStringSlice) => testDoubleDecoding(slice, LITTLE_ENDIAN) } } @@ -1296,7 +1296,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "function as expected" when { "putting Bytes, using putByte and putBytes" in { // mixing putByte and putBytes here for more rigorous testing - check { slice: ArraySlice[Byte] => + check { (slice: ArraySlice[Byte]) => val (data, from, to) = slice val builder = ByteString.newBuilder for (i <- 0 until from) builder.putByte(data(i)) @@ -1308,7 +1308,7 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "putting Bytes, using the OutputStream wrapper" in { // mixing the write methods here for more rigorous testing - check { slice: ArraySlice[Byte] => + check { (slice: ArraySlice[Byte]) => val (data, from, to) = slice val builder = ByteString.newBuilder for (i <- 0 until from) builder.asOutputStream.write(data(i).toInt) @@ -1321,62 +1321,62 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "encode data correctly" when { "encoding Short in big-endian" in { - check { slice: ArraySlice[Short] => + check { (slice: ArraySlice[Short]) => testShortEncoding(slice, BIG_ENDIAN) } } "encoding Short in little-endian" in { - check { slice: ArraySlice[Short] => + check { (slice: ArraySlice[Short]) => testShortEncoding(slice, LITTLE_ENDIAN) } } "encoding Int in big-endian" in { - check { slice: ArraySlice[Int] => + check { (slice: ArraySlice[Int]) => testIntEncoding(slice, BIG_ENDIAN) } } "encoding Int in little-endian" in { - check { slice: ArraySlice[Int] => + check { (slice: ArraySlice[Int]) => testIntEncoding(slice, LITTLE_ENDIAN) } } "encoding Long in big-endian" in { - check { slice: ArraySlice[Long] => + check { (slice: ArraySlice[Long]) => testLongEncoding(slice, BIG_ENDIAN) } } "encoding Long in little-endian" in { - check { slice: ArraySlice[Long] => + check { (slice: ArraySlice[Long]) => testLongEncoding(slice, LITTLE_ENDIAN) } } "encoding LongPart in big-endian" in { - check { slice: ArrayNumBytes[Long] => + check { (slice: ArrayNumBytes[Long]) => testLongPartEncoding(slice, BIG_ENDIAN) } } "encoding LongPart in little-endian" in { - check { slice: ArrayNumBytes[Long] => + check { (slice: ArrayNumBytes[Long]) => testLongPartEncoding(slice, LITTLE_ENDIAN) } } "encoding Float in big-endian" in { - check { slice: ArraySlice[Float] => + check { (slice: ArraySlice[Float]) => testFloatEncoding(slice, BIG_ENDIAN) } } "encoding Float in little-endian" in { - check { slice: ArraySlice[Float] => + check { (slice: ArraySlice[Float]) => testFloatEncoding(slice, LITTLE_ENDIAN) } } "encoding Double in big-endian" in { - check { slice: ArraySlice[Double] => + check { (slice: ArraySlice[Double]) => testDoubleEncoding(slice, BIG_ENDIAN) } } "encoding Double in little-endian" in { - check { slice: ArraySlice[Double] => + check { (slice: ArraySlice[Double]) => testDoubleEncoding(slice, LITTLE_ENDIAN) } } @@ -1384,12 +1384,12 @@ class ByteStringSpec extends AnyWordSpec with Matchers with Checkers { "have correct empty info" when { "is empty" in { - check { a: ByteStringBuilder => + check { (a: ByteStringBuilder) => a.isEmpty } } "is nonEmpty" in { - check { a: ByteStringBuilder => + check { (a: ByteStringBuilder) => a.putByte(1.toByte) a.nonEmpty } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorRefIgnoreSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorRefIgnoreSpec.scala index 650ac6f12d..706bbf39d1 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorRefIgnoreSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorRefIgnoreSpec.scala @@ -84,7 +84,7 @@ class ActorRefIgnoreSpec extends ScalaTestWithActorTestKit() with AnyWordSpecLik val failedAsk = askMeRef - .ask { _: ActorRef[Request] => + .ask { (_: ActorRef[Request]) => Request(testKit.system.ignoreRef) // <- pass the ignoreRef instead, so Future never completes } .failed diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/internal/ActorSystemSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/internal/ActorSystemSpec.scala index 416611b8b7..81435a0c29 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/internal/ActorSystemSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/internal/ActorSystemSpec.scala @@ -75,7 +75,7 @@ class ActorSystemSpec Behaviors.receiveMessage[Done] { _ => Behaviors.stopped } - withSystem("shutdown", stoppable, doTerminate = false) { sys: ActorSystem[Done] => + withSystem("shutdown", stoppable, doTerminate = false) { (sys: ActorSystem[Done]) => sys ! Done sys.whenTerminated.futureValue } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/receptionist/ReceptionistApiSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/receptionist/ReceptionistApiSpec.scala index 334ecb41f1..63d2285fdd 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/receptionist/ReceptionistApiSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/receptionist/ReceptionistApiSpec.scala @@ -59,7 +59,7 @@ object ReceptionistApiSpec { // another more "normal" is subscribe using an adapter // FIXME inference doesn't work with partial function - val adapter = context.spawnMessageAdapter { listing: Receptionist.Listing => + val adapter = context.spawnMessageAdapter { (listing: Receptionist.Listing) => listing.serviceInstances(key) // Set[ActorRef[String]] !! } context.system.receptionist ! Receptionist.Subscribe(key, adapter) diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/FSMDocSpec.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/FSMDocSpec.scala index 8df729b20f..7d86a932b9 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/FSMDocSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/FSMDocSpec.scala @@ -43,7 +43,7 @@ object FSMDocSpec { // initial state def apply(): Behavior[Event] = idle(Uninitialized) - private def idle(data: Data): Behavior[Event] = Behaviors.receiveMessage[Event] { message: Event => + private def idle(data: Data): Behavior[Event] = Behaviors.receiveMessage[Event] { message => (message, data) match { case (SetTarget(ref), Uninitialized) => idle(Todo(ref, Vector.empty)) diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala index 11c4dda25f..0acae5a1cc 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/internal/ExtensionsImpl.scala @@ -20,7 +20,7 @@ import akka.util.ccompat.JavaConverters._ * Actor system extensions registry */ @InternalApi -private[akka] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] => +private[akka] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] with InternalRecipientRef[_] => private val extensions = new ConcurrentHashMap[ExtensionId[_], AnyRef] @@ -55,9 +55,8 @@ private[akka] trait ExtensionsImpl extends Extensions { self: ActorSystem[_] => def idFromJavaSingletonAccessor(extensionIdFQCN: String): Try[ExtensionId[Extension]] = dynamicAccess.getClassFor[ExtensionId[Extension]](extensionIdFQCN).flatMap[ExtensionId[Extension]] { - clazz: Class[_] => + (clazz: Class[_]) => Try { - val singletonAccessor = clazz.getDeclaredMethod("getInstance") singletonAccessor.invoke(null).asInstanceOf[ExtensionId[Extension]] } diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index 268bb923f0..b827771f1a 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -103,7 +103,7 @@ object ActorRef { * the unique id of the actor is not taken into account when comparing actor paths. */ abstract class ActorRef extends java.lang.Comparable[ActorRef] with Serializable { - scalaRef: InternalActorRef => + scalaRef: InternalActorRef with ActorRefScope => /** * Returns the path for this actor (from this actor up to the root actor). @@ -166,7 +166,7 @@ abstract class ActorRef extends java.lang.Comparable[ActorRef] with Serializable * There are implicit conversions in package.scala * from ActorRef -> ScalaActorRef and back */ -trait ScalaActorRef { ref: ActorRef => +trait ScalaActorRef { ref: ActorRef with InternalActorRef with ActorRefScope => /** * Sends a one-way asynchronous message. E.g. fire-and-forget semantics. diff --git a/akka-actor/src/main/scala/akka/dispatch/CachingConfig.scala b/akka-actor/src/main/scala/akka/dispatch/CachingConfig.scala index 2210b41d55..4ca8d8233b 100644 --- a/akka-actor/src/main/scala/akka/dispatch/CachingConfig.scala +++ b/akka-actor/src/main/scala/akka/dispatch/CachingConfig.scala @@ -8,6 +8,7 @@ import java.util import java.util.concurrent.{ ConcurrentHashMap, TimeUnit } import scala.util.{ Failure, Success, Try } +import java.lang.Enum import com.typesafe.config._ diff --git a/akka-actor/src/main/scala/akka/japi/JavaAPI.scala b/akka-actor/src/main/scala/akka/japi/JavaAPI.scala index 9531a25f29..f3b73d4c95 100644 --- a/akka-actor/src/main/scala/akka/japi/JavaAPI.scala +++ b/akka-actor/src/main/scala/akka/japi/JavaAPI.scala @@ -258,7 +258,7 @@ object Util { if (i.hasNext) { val builder = new immutable.VectorBuilder[T] - do { builder += i.next() } while (i.hasNext) + while ({ builder += i.next(); i.hasNext }) () builder.result() } else EmptyImmutableSeq diff --git a/akka-actor/src/main/scala/akka/util/Index.scala b/akka-actor/src/main/scala/akka/util/Index.scala index 4911aedf5b..6badd5961a 100644 --- a/akka-actor/src/main/scala/akka/util/Index.scala +++ b/akka-actor/src/main/scala/akka/util/Index.scala @@ -22,9 +22,7 @@ import akka.util.ccompat.JavaConverters._ class Index[K, V](val mapSize: Int, val valueComparator: Comparator[V]) { def this(mapSize: Int, cmp: (V, V) => Int) = - this(mapSize, new Comparator[V] { - def compare(a: V, b: V): Int = cmp(a, b) - }) + this(mapSize, ((a: V, b: V) => cmp(a, b)): Comparator[V]) private val container = new ConcurrentHashMap[K, ConcurrentSkipListSet[V]](mapSize) private val emptySet = new ConcurrentSkipListSet[V] diff --git a/akka-remote-tests/src/test/scala/akka/remote/testkit/LogRoleReplace.scala b/akka-remote-tests/src/test/scala/akka/remote/testkit/LogRoleReplace.scala index e8697fca5e..03e8d3708d 100644 --- a/akka-remote-tests/src/test/scala/akka/remote/testkit/LogRoleReplace.scala +++ b/akka-remote-tests/src/test/scala/akka/remote/testkit/LogRoleReplace.scala @@ -91,7 +91,7 @@ class LogRoleReplace { private val RoleStarted = """\[([\w\-]+)\].*Role \[([\w]+)\] started with address \[[\w\-\+\.]+://.*@([\w\-\.]+):([0-9]+)\]""".r - private val ColorCode = """\u001B?\[[0-9]+m""" + private val ColorCode = "\u001B?\\[[0-9]+m" private var replacements: Map[String, String] = Map.empty diff --git a/akka-remote/src/main/scala/akka/remote/PhiAccrualFailureDetector.scala b/akka-remote/src/main/scala/akka/remote/PhiAccrualFailureDetector.scala index 8a74c11057..5b2e413f13 100644 --- a/akka-remote/src/main/scala/akka/remote/PhiAccrualFailureDetector.scala +++ b/akka-remote/src/main/scala/akka/remote/PhiAccrualFailureDetector.scala @@ -204,7 +204,7 @@ class PhiAccrualFailureDetector( -math.log10(1.0 - 1.0 / (1.0 + e)) } - private val minStdDeviationMillis = minStdDeviation.toMillis + private val minStdDeviationMillis = minStdDeviation.toMillis.toDouble private def ensureValidStdDeviation(stdDeviation: Double): Double = math.max(stdDeviation, minStdDeviationMillis) diff --git a/akka-remote/src/test/scala/akka/remote/artery/tcp/TlsTcpSpec.scala b/akka-remote/src/test/scala/akka/remote/artery/tcp/TlsTcpSpec.scala index b530ffa0f9..4f874dffe3 100644 --- a/akka-remote/src/test/scala/akka/remote/artery/tcp/TlsTcpSpec.scala +++ b/akka-remote/src/test/scala/akka/remote/artery/tcp/TlsTcpSpec.scala @@ -53,14 +53,15 @@ class TlsTcpWithRotatingKeysSSLEngineSpec extends TlsTcpSpec(ConfigFactory.parse akka.remote.artery.ssl { ssl-engine-provider = akka.remote.artery.tcp.ssl.RotatingKeysSSLEngineProvider rotating-keys-engine { - key-file = ${getClass.getClassLoader.getResource("ssl/node.example.com.pem").getPath} - cert-file = ${getClass.getClassLoader.getResource("ssl/node.example.com.crt").getPath} - ca-cert-file = ${getClass.getClassLoader.getResource("ssl/exampleca.crt").getPath} + key-file = ${TlsTcpSpec.resourcePath("ssl/node.example.com.pem")} + cert-file = ${TlsTcpSpec.resourcePath("ssl/node.example.com.crt")} + ca-cert-file = ${TlsTcpSpec.resourcePath("ssl/exampleca.crt")} } } """)) object TlsTcpSpec { + def resourcePath(name: String): String = getClass.getClassLoader.getResource(name).getPath lazy val config: Config = { ConfigFactory.parseString(s""" diff --git a/akka-slf4j/src/test/scala/akka/event/slf4j/Slf4jLoggerSpec.scala b/akka-slf4j/src/test/scala/akka/event/slf4j/Slf4jLoggerSpec.scala index 7169076a27..950dab0dbe 100644 --- a/akka-slf4j/src/test/scala/akka/event/slf4j/Slf4jLoggerSpec.scala +++ b/akka-slf4j/src/test/scala/akka/event/slf4j/Slf4jLoggerSpec.scala @@ -63,7 +63,7 @@ object Slf4jLoggerSpec { val output = new ByteArrayOutputStream def outputString: String = output.toString("UTF-8") - class TestAppender extends OutputStreamAppender { + class TestAppender[E] extends OutputStreamAppender[E] { override def start(): Unit = { setOutputStream(output) diff --git a/akka-testkit/src/test/scala/akka/testkit/WithLogCapturing.scala b/akka-testkit/src/test/scala/akka/testkit/WithLogCapturing.scala index 984fff4d3f..92fb7447a3 100644 --- a/akka-testkit/src/test/scala/akka/testkit/WithLogCapturing.scala +++ b/akka-testkit/src/test/scala/akka/testkit/WithLogCapturing.scala @@ -56,7 +56,7 @@ trait WithLogCapturing extends SuiteMixin { this: TestSuite => override def write(b: Int): Unit = oldOut.write(b) }) { override def println(x: Any): Unit = - oldOut.println(prefix + String.valueOf(x).replaceAllLiterally("\n", s"\n$prefix")) + oldOut.println(prefix + String.valueOf(x).replace("\n", s"\n$prefix")) } Console.withOut(prefixingOut) { diff --git a/akka-testkit/src/test/scala/akka/testkit/metrics/reporter/AkkaConsoleReporter.scala b/akka-testkit/src/test/scala/akka/testkit/metrics/reporter/AkkaConsoleReporter.scala index 72c7946ef5..19d912e776 100644 --- a/akka-testkit/src/test/scala/akka/testkit/metrics/reporter/AkkaConsoleReporter.scala +++ b/akka-testkit/src/test/scala/akka/testkit/metrics/reporter/AkkaConsoleReporter.scala @@ -98,8 +98,8 @@ class AkkaConsoleReporter(registry: AkkaMetricRegistry, verbose: Boolean, output output.print(" 1-minute rate = %2.2f calls/%s%n".format(convertRate(timer.getOneMinuteRate), getRateUnit)) output.print(" 5-minute rate = %2.2f calls/%s%n".format(convertRate(timer.getFiveMinuteRate), getRateUnit)) output.print(" 15-minute rate = %2.2f calls/%s%n".format(convertRate(timer.getFifteenMinuteRate), getRateUnit)) - output.print(" min = %2.2f %s%n".format(convertDuration(snapshot.getMin), getDurationUnit)) - output.print(" max = %2.2f %s%n".format(convertDuration(snapshot.getMax), getDurationUnit)) + output.print(" min = %2.2f %s%n".format(convertDuration(snapshot.getMin.toDouble), getDurationUnit)) + output.print(" max = %2.2f %s%n".format(convertDuration(snapshot.getMax.toDouble), getDurationUnit)) output.print(" mean = %2.2f %s%n".format(convertDuration(snapshot.getMean), getDurationUnit)) output.print(" stddev = %2.2f %s%n".format(convertDuration(snapshot.getStdDev), getDurationUnit)) output.print(" median = %2.2f %s%n".format(convertDuration(snapshot.getMedian), getDurationUnit))