diff --git a/.travis.yml b/.travis.yml index 15a17c13ed..4edcc179cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,7 +38,7 @@ jobs: - stage: scala3 name: scala3 # separate job since only a few modules compile with Scala 3 yet - script: jabba install adopt@1.11-0 && jabba use adopt@1.11-0 && sbt -Dakka.build.scalaVersion=3.0 "akka-actor-tests/test:compile" akka-actor-testkit-typed/compile akka-actor-typed/compile akka-discovery/test akka-pki/test:compile akka-protobuf/test:compile akka-protobuf-v3/test:compile akka-slf4j/test:compile akka-stream/compile akka-stream-tests-tck/test akka-coordination/test akka-serialization-jackson/test:compile akka-testkit/test akka-stream-testkit/test akka-remote/compile + script: jabba install adopt@1.11-0 && jabba use adopt@1.11-0 && sbt -jvm-opts .jvmopts-travis -Dakka.build.scalaVersion=3.0 "akka-actor-tests/test:compile" akka-actor-testkit-typed/compile akka-actor-typed/compile akka-actor-typed-tests/test akka-discovery/test akka-pki/test:compile akka-protobuf/test:compile akka-protobuf-v3/test:compile akka-slf4j/test:compile akka-stream/compile akka-stream-tests-tck/test akka-coordination/test akka-serialization-jackson/test:compile akka-testkit/test akka-stream-testkit/test akka-remote/compile stages: - name: whitesource diff --git a/akka-actor-tests/src/test/java/akka/actor/AbstractFSMActorTest.java b/akka-actor-tests/src/test/java/akka/actor/AbstractFSMActorTest.java index d30f53fb8d..2f12d9414d 100644 --- a/akka-actor-tests/src/test/java/akka/actor/AbstractFSMActorTest.java +++ b/akka-actor-tests/src/test/java/akka/actor/AbstractFSMActorTest.java @@ -13,6 +13,8 @@ import org.scalatestplus.junit.JUnitSuite; public class AbstractFSMActorTest extends JUnitSuite { + // javac produces an `unchecked` warning about `akka$actor$FSM$$transitionEvent` + // https://github.com/lampepfl/dotty/issues/6350 public static class MyFSM extends AbstractFSM { private final ActorRef probe; diff --git a/akka-actor-typed-tests/src/test/java/jdocs/akka/typed/IntroTest.java b/akka-actor-typed-tests/src/test/java/jdocs/akka/typed/IntroTest.java index dd28926550..8443c1da0e 100644 --- a/akka-actor-typed-tests/src/test/java/jdocs/akka/typed/IntroTest.java +++ b/akka-actor-typed-tests/src/test/java/jdocs/akka/typed/IntroTest.java @@ -147,15 +147,6 @@ public interface IntroTest { // #hello-world-main interface CustomDispatchersExample { - - public static class SayHello { - public final String name; - - public SayHello(String name) { - this.name = name; - } - } - // #hello-world-main-with-dispatchers public class HelloWorldMain extends AbstractBehavior { diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorContextSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorContextSpec.scala index 258a715221..d504ca2503 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorContextSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ActorContextSpec.scala @@ -647,7 +647,8 @@ abstract class ActorContextSpec extends ScalaTestWithActorTestKit with AnyWordSp } "not allow null messages" in { - val actor = spawn(Behaviors.empty[Null].decorate) + // Scala 3 doesn't generate an implicit `ClassTag[Null]` (https://github.com/lampepfl/dotty/issues/9586) + val actor = spawn(decoration(ClassTag.Null)(Behaviors.empty[Null])) intercept[InvalidMessageException] { actor ! null } 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 f989dbabca..92901208ca 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 @@ -44,7 +44,7 @@ class ActorRefIgnoreSpec extends ScalaTestWithActorTestKit() with AnyWordSpecLik implicit val timeout: Timeout = 1.second // send a message to interactWithRef - context.ask(askMeRef, Request) { + context.ask(askMeRef, Request.apply) { case Success(res) => res case Failure(ex) => throw ex } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/AskSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/AskSpec.scala index a9aad8f79b..58dfae00ac 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/AskSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/AskSpec.scala @@ -50,7 +50,7 @@ class AskSpec extends ScalaTestWithActorTestKit(""" "Ask pattern" must { "fail the future if the actor is already terminated" in { val ref = spawn(behavior) - val stopResult: Future[Unit] = ref.ask(Stop) + val stopResult: Future[Unit] = ref.ask(Stop.apply) stopResult.futureValue val probe = createTestProbe() @@ -131,7 +131,7 @@ class AskSpec extends ScalaTestWithActorTestKit(""" import akka.actor.typed.scaladsl.adapter._ implicit val timeout: Timeout = 3.seconds val typedLegacy: ActorRef[AnyRef] = legacyActor - (typedLegacy.ask(Ping)).failed.futureValue should ===(ex) + typedLegacy.ask(Ping.apply).failed.futureValue should ===(ex) } finally { akka.testkit.TestKit.shutdownActorSystem(classicSystem) } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/BehaviorSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/BehaviorSpec.scala index 74a0e7d312..7914c5ca2b 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/BehaviorSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/BehaviorSpec.scala @@ -448,7 +448,7 @@ class MutableScalaBehaviorSpec extends Messages with Become with Stoppable { override def onMessage(message: Command): Behavior[Command] = { message match { case GetSelf => - monitor ! Self(context.self) + monitor ! Self(this.context.self) this case Miss => monitor ! Missed diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ExtensionsSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ExtensionsSpec.scala index 9dee4cba6a..af9db0ab67 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ExtensionsSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/ExtensionsSpec.scala @@ -263,7 +263,9 @@ class ExtensionsSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with } val sys = setup match { case None => ActorSystem[Any](Behaviors.empty[Any], name, bootstrap) - case Some(s) => ActorSystem[Any](Behaviors.empty[Any], name, s.and(bootstrap)) + case Some(s) => + // explicit Props.empty: https://github.com/lampepfl/dotty/issues/12679 + ActorSystem[Any](Behaviors.empty[Any], name, s.and(bootstrap), Props.empty) } try f(sys) diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala index 655836fad2..a4a1ef68a7 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/MailboxSelectorSpec.scala @@ -51,13 +51,13 @@ class MailboxSelectorSpec extends ScalaTestWithActorTestKit(""" "The Mailbox selectors" must { "default to unbounded" in { val actor = spawn(behavior) - val mailbox = actor.ask(WhatsYourMailbox).futureValue + val mailbox = actor.ask(WhatsYourMailbox.apply).futureValue mailbox shouldBe a[UnboundedMessageQueueSemantics] } "select a bounded mailbox" in { val actor = spawn(behavior, MailboxSelector.bounded(3)) - val mailbox = actor.ask(WhatsYourMailbox).futureValue + val mailbox = actor.ask(WhatsYourMailbox.apply).futureValue mailbox shouldBe a[BoundedMessageQueueSemantics] // capacity is private so only way to test is to fill mailbox } @@ -85,7 +85,7 @@ class MailboxSelectorSpec extends ScalaTestWithActorTestKit(""" "select an arbitrary mailbox from config" in { val actor = spawn(behavior, MailboxSelector.fromConfig("specific-mailbox")) - val mailbox = actor.ask(WhatsYourMailbox).futureValue + val mailbox = actor.ask(WhatsYourMailbox.apply).futureValue mailbox shouldBe a[BoundedMessageQueueSemantics] mailbox.asInstanceOf[BoundedNodeMessageQueue].capacity should ===(4) diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextAskSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextAskSpec.scala index 1141f87872..8fd28930b0 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextAskSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/ActorContextAskSpec.scala @@ -53,7 +53,7 @@ class ActorContextAskSpec val snitch = Behaviors.setup[Pong] { context => // Timeout comes from TypedAkkaSpec - context.ask(pingPong, Ping) { + context.ask(pingPong, Ping.apply) { case Success(_) => Pong(context.self.path.name + "1", Thread.currentThread().getName) case Failure(ex) => throw ex } @@ -86,7 +86,7 @@ class ActorContextAskSpec }) val snitch = Behaviors.setup[AnyRef] { context => - context.ask(pingPong, Ping) { + context.ask(pingPong, Ping.apply) { case Success(message) => throw new NotImplementedError(message.toString) case Failure(x) => x } @@ -194,7 +194,7 @@ class ActorContextAskSpec val probe = createTestProbe[Any]() spawn(Behaviors.setup[Pong.type] { ctx => - ctx.askWithStatus(probe.ref, Ping) { + ctx.askWithStatus(probe.ref, Ping.apply) { case Success(Pong) => Pong case Failure(ex) => throw ex } @@ -217,7 +217,7 @@ class ActorContextAskSpec val probe = createTestProbe[Any]() spawn(Behaviors.setup[Throwable] { ctx => - ctx.askWithStatus(probe.ref, Ping) { + ctx.askWithStatus(probe.ref, Ping.apply) { case Failure(ex) => ex case wat => throw new IllegalArgumentException(s"Unexpected response $wat") } @@ -241,7 +241,7 @@ class ActorContextAskSpec val probe = createTestProbe[Any]() case class Message(any: Any) spawn(Behaviors.setup[Throwable] { ctx => - ctx.askWithStatus(probe.ref, Ping) { + ctx.askWithStatus(probe.ref, Ping.apply) { case Failure(ex) => ex case wat => throw new IllegalArgumentException(s"Unexpected response $wat") } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/MessageAdapterSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/MessageAdapterSpec.scala index d27d66bc21..ae37f7f8dd 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/MessageAdapterSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/MessageAdapterSpec.scala @@ -281,7 +281,7 @@ class MessageAdapterSpec val deadLetterProbe = testKit.createDeadLetterProbe() val snitch = Behaviors.setup[PingReply] { context => - val replyTo = context.messageAdapter[Pong](PingReply) + val replyTo = context.messageAdapter[Pong](PingReply.apply) pingProbe.ref ! Ping(replyTo) Behaviors.stopped } diff --git a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/StashSpec.scala b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/StashSpec.scala index 49f71abf36..a50bec47dd 100644 --- a/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/StashSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/akka/actor/typed/scaladsl/StashSpec.scala @@ -76,7 +76,7 @@ object AbstractStashSpec { context.self ! Unstash // continue unstashing until buffer is empty val numberOfMessages = 2 context.log.debug(s"Unstash $numberOfMessages of ${buffer.size}, starting with ${buffer.head}") - buffer.unstash(unstashing(processed), numberOfMessages, Unstashed) + buffer.unstash(unstashing(processed), numberOfMessages, Unstashed.apply) } case Stash => Behaviors.unhandled @@ -113,7 +113,7 @@ object AbstractStashSpec { context.self ! Unstash // continue unstashing until buffer is empty val numberOfMessages = 2 context.log.debug(s"Unstash $numberOfMessages of ${buffer.size}, starting with ${buffer.head}") - buffer.unstash(unstashing(processed), numberOfMessages, Unstashed) + buffer.unstash(unstashing(processed), numberOfMessages, Unstashed.apply) } case GetStashSize(replyTo) => replyTo ! buffer.size @@ -166,7 +166,7 @@ object AbstractStashSpec { context.self ! Unstash // continue unstashing until buffer is empty val numberOfMessages = 2 context.log.debug(s"Unstash $numberOfMessages of ${buffer.size}, starting with ${buffer.head}") - buffer.unstash(this, numberOfMessages, Unstashed) + buffer.unstash(this, numberOfMessages, Unstashed.apply) } case Unstashed(message: Msg) => context.log.debug(s"unstashed $message") diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/InteractionPatternsSpec.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/InteractionPatternsSpec.scala index 90fd016901..447e1338fc 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/InteractionPatternsSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/InteractionPatternsSpec.scala @@ -80,7 +80,7 @@ class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpec val probe = createTestProbe[CookieFabric.Response]() // shhh, don't tell anyone import scala.language.reflectiveCalls - val context = new { + val context: { def self: ActorRef[CookieFabric.Response] } = new { def self = probe.ref } @@ -259,7 +259,7 @@ class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpec // as OpenThePodBayDoorsPlease is a case class it has a factory apply method // that is what we are passing as the second parameter here it could also be written // as `ref => OpenThePodBayDoorsPlease(ref)` - context.ask(hal, Hal.OpenThePodBayDoorsPlease) { + context.ask(hal, Hal.OpenThePodBayDoorsPlease.apply) { case Success(Hal.Response(message)) => AdaptedResponse(message) case Failure(_) => AdaptedResponse("Request failed") } @@ -269,7 +269,7 @@ class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpec // changed at the time the response arrives and the transformation is done, best is to // use immutable state we have closed over like here. val requestId = 1 - context.ask(hal, Hal.OpenThePodBayDoorsPlease) { + context.ask(hal, Hal.OpenThePodBayDoorsPlease.apply) { case Success(Hal.Response(message)) => AdaptedResponse(s"$requestId: $message") case Failure(_) => AdaptedResponse(s"$requestId: Request failed") } @@ -324,7 +324,7 @@ class InteractionPatternsSpec extends ScalaTestWithActorTestKit with AnyWordSpec // A StatusReply.Success(m) ends up as a Success(m) here, while a // StatusReply.Error(text) becomes a Failure(ErrorMessage(text)) - context.askWithStatus(hal, Hal.OpenThePodBayDoorsPlease) { + context.askWithStatus(hal, Hal.OpenThePodBayDoorsPlease.apply) { case Success(message) => AdaptedResponse(message) case Failure(StatusReply.ErrorMessage(text)) => AdaptedResponse(s"Request denied: $text") case Failure(_) => AdaptedResponse("Request failed") diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/OOIntroSpec.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/OOIntroSpec.scala index ca453cd78a..7f715f7af4 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/OOIntroSpec.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/OOIntroSpec.scala @@ -69,7 +69,7 @@ object OOIntroSpec { } } - object SessionBehavior { + private object SessionBehavior { def apply( room: ActorRef[PublishSessionMessage], screenName: String, diff --git a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/StyleGuideDocExamples.scala b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/StyleGuideDocExamples.scala index 47b0941cc4..8135746549 100644 --- a/akka-actor-typed-tests/src/test/scala/docs/akka/typed/StyleGuideDocExamples.scala +++ b/akka-actor-typed-tests/src/test/scala/docs/akka/typed/StyleGuideDocExamples.scala @@ -485,14 +485,16 @@ object StyleGuideDocExamples { @nowarn private def counter(remaining: Int): Behavior[Command] = { //#pattern-match-without-guard - Behaviors.receiveMessage { - case Down => - if (remaining == 1) { - notifyWhenZero.tell(Done) - zero - } else - counter(remaining - 1) - } + // `@unchecked` for Scala 3, which doesn't support @nowarn + Behaviors.receiveMessage(x => + (x: @unchecked) match { + case Down => + if (remaining == 1) { + notifyWhenZero.tell(Done) + zero + } else + counter(remaining - 1) + }) //#pattern-match-without-guard } diff --git a/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/BehaviorBuilder.scala b/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/BehaviorBuilder.scala index 66c0e38edf..9a99601759 100644 --- a/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/BehaviorBuilder.scala +++ b/akka-actor-typed/src/main/scala/akka/actor/typed/javadsl/BehaviorBuilder.scala @@ -167,6 +167,7 @@ object BehaviorBuilder { /** * @return new empty immutable behavior builder. */ + // Empty param list to work around https://github.com/lampepfl/dotty/issues/10347 def create[T]: BehaviorBuilder[T] = _empty.asInstanceOf[BehaviorBuilder[T]] }