Skip to content

Commit

Permalink
dotty phase 2: scalafix ExplicitNonNullaryApply (#28949)
Browse files Browse the repository at this point in the history
* scalafix ExplicitNonNullaryApply prepare

+ Temporarily use com.sandinh:sbt-scalafix because scalacenter/scalafix#1098
+ Add ExplicitNonNullaryApply rule to .scalafix.conf
+ Manually fix a NonNullaryApply case in DeathWatchSpec that cause
  `fixall` fail because ExplicitNonNullaryApply rule incorrectly rewrite
  `context unbecome` to `context unbecome()` instead of `context.unbecome()`

* scalafix ExplicitNonNullaryApply

fix by enabling only ExplicitNonNullaryApply rule in .scalafix.conf then:
```
% sbt -Dakka.build.scalaVersion=2.13.1
> fixall
```

* scalafmtAll

* Revert to ch.epfl.scala:sbt-scalafix

Co-authored-by: Bùi Việt Thành <thanhbv@sandinh.net>
  • Loading branch information
ohze and giabao authored Apr 27, 2020
1 parent 4ba835d commit ea7205e
Show file tree
Hide file tree
Showing 266 changed files with 929 additions and 919 deletions.
1 change: 1 addition & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
rules = [
RemoveUnused
ExplicitResultTypes
"github:ohze/scalafix-rules/ExplicitNonNullaryApply"
"github:ohze/scalafix-rules/ConstructorProcedureSyntax"
"github:ohze/scalafix-rules/FinalObject"
"github:ohze/scalafix-rules/Any2StringAdd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ import org.slf4j.LoggerFactory

override def scheduler: Scheduler = throw new UnsupportedOperationException("no scheduler")

private val terminationPromise = Promise[Done]
private val terminationPromise = Promise[Done]()
override def terminate(): Unit = terminationPromise.trySuccess(Done)
override def whenTerminated: Future[Done] = terminationPromise.future
override def getWhenTerminated: CompletionStage[Done] = FutureConverters.toJava(whenTerminated)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private[akka] final class BehaviorTestKitImpl[T](_path: ActorPath, _initialBehav
} catch handleException
}

override def runOne(): Unit = run(selfInbox.receiveMessage())
override def runOne(): Unit = run(selfInbox().receiveMessage())

override def signal(signal: Signal): Unit = {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private[akka] final class FunctionRef[-T](override val path: ActorPath, send: (T
new FunctionRef[U](p, (message, _) => {
val m = f(message);
if (m != null) {
selfInbox.ref ! m; i.selfInbox.ref ! message
selfInbox.ref ! m; i.selfInbox().ref ! message
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class BehaviorTestKit[T] {
/**
* The self reference of the actor living inside this testkit.
*/
def getRef(): ActorRef[T] = selfInbox.getRef()
def getRef(): ActorRef[T] = selfInbox().getRef()

/**
* Requests all the effects. The effects are consumed, subsequent calls will only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ trait BehaviorTestKit[T] {
/**
* The self reference of the actor living inside this testkit.
*/
def ref: ActorRef[T] = selfInbox.ref
def ref: ActorRef[T] = selfInbox().ref

/**
* Requests all the effects. The effects are consumed, subsequent calls will only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class TestProbeSpec extends ScalaTestWithActorTestKit with AnyWordSpecLike with
val probe = createTestProbe[EventT]()
eventsT(10).forall { e =>
probe.ref ! e
probe.receiveMessage == e
probe.receiveMessage() == e
} should ===(true)

probe.expectNoMessage()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,56 @@ class ActorConfigurationVerificationSpec
"An Actor configured with a BalancingDispatcher" must {
"fail verification with a ConfigurationException if also configured with a RoundRobinPool" in {
intercept[ConfigurationException] {
system.actorOf(RoundRobinPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]))
system.actorOf(RoundRobinPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]()))
}
}
"fail verification with a ConfigurationException if also configured with a BroadcastPool" in {
intercept[ConfigurationException] {
system.actorOf(BroadcastPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]))
system.actorOf(BroadcastPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]()))
}
}
"fail verification with a ConfigurationException if also configured with a RandomPool" in {
intercept[ConfigurationException] {
system.actorOf(RandomPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]))
system.actorOf(RandomPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]()))
}
}
"fail verification with a ConfigurationException if also configured with a SmallestMailboxPool" in {
intercept[ConfigurationException] {
system.actorOf(SmallestMailboxPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]))
system.actorOf(SmallestMailboxPool(2).withDispatcher("balancing-dispatcher").props(Props[TestActor]()))
}
}
"fail verification with a ConfigurationException if also configured with a ScatterGatherFirstCompletedPool" in {
intercept[ConfigurationException] {
system.actorOf(
ScatterGatherFirstCompletedPool(nrOfInstances = 2, within = 2 seconds)
.withDispatcher("balancing-dispatcher")
.props(Props[TestActor]))
.props(Props[TestActor]()))
}
}
"not fail verification with a ConfigurationException also not configured with a Router" in {
system.actorOf(Props[TestActor].withDispatcher("balancing-dispatcher"))
system.actorOf(Props[TestActor]().withDispatcher("balancing-dispatcher"))
}
}
"An Actor configured with a non-balancing dispatcher" must {
"not fail verification with a ConfigurationException if also configured with a Router" in {
system.actorOf(RoundRobinPool(2).props(Props[TestActor].withDispatcher("pinned-dispatcher")))
system.actorOf(RoundRobinPool(2).props(Props[TestActor]().withDispatcher("pinned-dispatcher")))
}

"fail verification if the dispatcher cannot be found" in {
intercept[ConfigurationException] {
system.actorOf(Props[TestActor].withDispatcher("does not exist"))
system.actorOf(Props[TestActor]().withDispatcher("does not exist"))
}
}

"fail verification if the dispatcher cannot be found for the head of a router" in {
intercept[ConfigurationException] {
system.actorOf(RoundRobinPool(1, routerDispatcher = "does not exist").props(Props[TestActor]))
system.actorOf(RoundRobinPool(1, routerDispatcher = "does not exist").props(Props[TestActor]()))
}
}

"fail verification if the dispatcher cannot be found for the routees of a router" in {
intercept[ConfigurationException] {
system.actorOf(RoundRobinPool(1).props(Props[TestActor].withDispatcher("does not exist")))
system.actorOf(RoundRobinPool(1).props(Props[TestActor]().withDispatcher("does not exist")))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,9 @@ class ActorCreationPerfSpec

"Actor creation with actorOf" must {

registerTests("Props[EmptyActor] with new Props", () => Props[EmptyActor])
registerTests("Props[EmptyActor] with new Props", () => Props[EmptyActor]())

val props1 = Props[EmptyActor]
val props1 = Props[EmptyActor]()
registerTests("Props[EmptyActor] with same Props", () => props1)

registerTests("Props(new EmptyActor) new", () => { Props(new EmptyActor) })
Expand Down
66 changes: 33 additions & 33 deletions akka-actor-tests/src/test/scala/akka/actor/ActorMailboxSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -242,22 +242,22 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
"An Actor" must {

"get an unbounded message queue by default" in {
checkMailboxQueue(Props[QueueReportingActor], "default-default", UnboundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "default-default", UnboundedMailboxTypes)
}

"get an unbounded deque message queue when it is only configured on the props" in {
checkMailboxQueue(
Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"),
Props[QueueReportingActor]().withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"default-override-from-props",
UnboundedDeqMailboxTypes)
}

"get an bounded message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(Props[BoundedQueueReportingActor], "default-override-from-trait", BoundedMailboxTypes)
checkMailboxQueue(Props[BoundedQueueReportingActor](), "default-override-from-trait", BoundedMailboxTypes)
}

"get an unbounded deque message queue when it's only mixed with Stash" in {
checkMailboxQueue(Props[StashQueueReportingActor], "default-override-from-stash", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props[StashQueueReportingActor](), "default-override-from-stash", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props(new StashQueueReportingActor), "default-override-from-stash2", UnboundedDeqMailboxTypes)
checkMailboxQueue(
Props(classOf[StashQueueReportingActorWithParams], 17, "hello"),
Expand All @@ -270,99 +270,99 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
}

"get a bounded message queue when it's configured as mailbox" in {
checkMailboxQueue(Props[QueueReportingActor], "default-bounded", BoundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "default-bounded", BoundedMailboxTypes)
}

"get an unbounded deque message queue when it's configured as mailbox" in {
checkMailboxQueue(Props[QueueReportingActor], "default-unbounded-deque", UnboundedDeqMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "default-unbounded-deque", UnboundedDeqMailboxTypes)
}

"get a bounded control aware message queue when it's configured as mailbox" in {
checkMailboxQueue(Props[QueueReportingActor], "default-bounded-control-aware", BoundedControlAwareMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "default-bounded-control-aware", BoundedControlAwareMailboxTypes)
}

"get an unbounded control aware message queue when it's configured as mailbox" in {
checkMailboxQueue(
Props[QueueReportingActor],
Props[QueueReportingActor](),
"default-unbounded-control-aware",
UnboundedControlAwareMailboxTypes)
}

"get an bounded control aware message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(
Props[BoundedControlAwareQueueReportingActor],
Props[BoundedControlAwareQueueReportingActor](),
"default-override-from-trait-bounded-control-aware",
BoundedControlAwareMailboxTypes)
}

"get an unbounded control aware message queue when it's only configured with RequiresMailbox" in {
checkMailboxQueue(
Props[UnboundedControlAwareQueueReportingActor],
Props[UnboundedControlAwareQueueReportingActor](),
"default-override-from-trait-unbounded-control-aware",
UnboundedControlAwareMailboxTypes)
}

"fail to create actor when an unbounded dequeu message queue is configured as mailbox overriding RequestMailbox" in {
intercept[ConfigurationException](
system.actorOf(Props[BoundedQueueReportingActor], "default-unbounded-deque-override-trait"))
system.actorOf(Props[BoundedQueueReportingActor](), "default-unbounded-deque-override-trait"))
}

"get an unbounded message queue when defined in dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor], "unbounded-default", UnboundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "unbounded-default", UnboundedMailboxTypes)
}

"fail to create actor when an unbounded message queue is defined in dispatcher overriding RequestMailbox" in {
intercept[ConfigurationException](
system.actorOf(Props[BoundedQueueReportingActor], "unbounded-default-override-trait"))
system.actorOf(Props[BoundedQueueReportingActor](), "unbounded-default-override-trait"))
}

"get a bounded message queue when it's configured as mailbox overriding unbounded in dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor], "unbounded-bounded", BoundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "unbounded-bounded", BoundedMailboxTypes)
}

"get a bounded message queue when defined in dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor], "bounded-default", BoundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "bounded-default", BoundedMailboxTypes)
}

"get a bounded message queue with 0 push timeout when defined in dispatcher" in {
val q = checkMailboxQueue(
Props[QueueReportingActor],
Props[QueueReportingActor](),
"default-bounded-mailbox-with-zero-pushtimeout",
BoundedMailboxTypes)
q.asInstanceOf[BoundedMessageQueueSemantics].pushTimeOut should ===(Duration.Zero)
}

"get an unbounded message queue when it's configured as mailbox overriding bounded in dispatcher" in {
checkMailboxQueue(Props[QueueReportingActor], "bounded-unbounded", UnboundedMailboxTypes)
checkMailboxQueue(Props[QueueReportingActor](), "bounded-unbounded", UnboundedMailboxTypes)
}

"get an unbounded message queue overriding configuration on the props" in {
checkMailboxQueue(
Props[QueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"),
Props[QueueReportingActor]().withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"bounded-unbounded-override-props",
UnboundedMailboxTypes)
}

"get a bounded deque-based message queue if configured and required" in {
checkMailboxQueue(
Props[StashQueueReportingActor],
Props[StashQueueReportingActor](),
"bounded-deque-requirements-configured",
BoundedDeqMailboxTypes)
}

"fail with a unbounded deque-based message queue if configured and required" in {
intercept[ConfigurationException](
system.actorOf(Props[StashQueueReportingActor], "bounded-deque-require-unbounded-configured"))
system.actorOf(Props[StashQueueReportingActor](), "bounded-deque-require-unbounded-configured"))
}

"fail with a bounded deque-based message queue if not configured" in {
intercept[ConfigurationException](
system.actorOf(Props[StashQueueReportingActor], "bounded-deque-require-unbounded-unconfigured"))
system.actorOf(Props[StashQueueReportingActor](), "bounded-deque-require-unbounded-unconfigured"))
}

"get a bounded deque-based message queue if configured and required with Props" in {
checkMailboxQueue(
Props[StashQueueReportingActor]
Props[StashQueueReportingActor]()
.withDispatcher("requiring-bounded-dispatcher")
.withMailbox("akka.actor.mailbox.bounded-deque-based"),
"bounded-deque-requirements-configured-props",
Expand All @@ -372,7 +372,7 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
"fail with a unbounded deque-based message queue if configured and required with Props" in {
intercept[ConfigurationException](
system.actorOf(
Props[StashQueueReportingActor]
Props[StashQueueReportingActor]()
.withDispatcher("requiring-bounded-dispatcher")
.withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"bounded-deque-require-unbounded-configured-props"))
Expand All @@ -381,67 +381,67 @@ class ActorMailboxSpec(conf: Config) extends AkkaSpec(conf) with DefaultTimeout
"fail with a bounded deque-based message queue if not configured with Props" in {
intercept[ConfigurationException](
system.actorOf(
Props[StashQueueReportingActor].withDispatcher("requiring-bounded-dispatcher"),
Props[StashQueueReportingActor]().withDispatcher("requiring-bounded-dispatcher"),
"bounded-deque-require-unbounded-unconfigured-props"))
}

"get a bounded deque-based message queue if configured and required with Props (dispatcher)" in {
checkMailboxQueue(
Props[StashQueueReportingActor].withDispatcher("requiring-bounded-dispatcher"),
Props[StashQueueReportingActor]().withDispatcher("requiring-bounded-dispatcher"),
"bounded-deque-requirements-configured-props-disp",
BoundedDeqMailboxTypes)
}

"fail with a unbounded deque-based message queue if configured and required with Props (dispatcher)" in {
intercept[ConfigurationException](
system.actorOf(
Props[StashQueueReportingActor].withDispatcher("requiring-bounded-dispatcher"),
Props[StashQueueReportingActor]().withDispatcher("requiring-bounded-dispatcher"),
"bounded-deque-require-unbounded-configured-props-disp"))
}

"fail with a bounded deque-based message queue if not configured with Props (dispatcher)" in {
intercept[ConfigurationException](
system.actorOf(
Props[StashQueueReportingActor].withDispatcher("requiring-bounded-dispatcher"),
Props[StashQueueReportingActor]().withDispatcher("requiring-bounded-dispatcher"),
"bounded-deque-require-unbounded-unconfigured-props-disp"))
}

"get a bounded deque-based message queue if configured and required with Props (mailbox)" in {
checkMailboxQueue(
Props[StashQueueReportingActor].withMailbox("akka.actor.mailbox.bounded-deque-based"),
Props[StashQueueReportingActor]().withMailbox("akka.actor.mailbox.bounded-deque-based"),
"bounded-deque-requirements-configured-props-mail",
BoundedDeqMailboxTypes)
}

"fail with a unbounded deque-based message queue if configured and required with Props (mailbox)" in {
intercept[ConfigurationException](
system.actorOf(
Props[StashQueueReportingActor].withMailbox("akka.actor.mailbox.unbounded-deque-based"),
Props[StashQueueReportingActor]().withMailbox("akka.actor.mailbox.unbounded-deque-based"),
"bounded-deque-require-unbounded-configured-props-mail"))
}

"fail with a bounded deque-based message queue if not configured with Props (mailbox)" in {
intercept[ConfigurationException](
system.actorOf(Props[StashQueueReportingActor], "bounded-deque-require-unbounded-unconfigured-props-mail"))
system.actorOf(Props[StashQueueReportingActor](), "bounded-deque-require-unbounded-unconfigured-props-mail"))
}

"get an unbounded message queue with a balancing dispatcher" in {
checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("balancing-dispatcher"),
Props[QueueReportingActor]().withDispatcher("balancing-dispatcher"),
"unbounded-balancing",
UnboundedMailboxTypes)
}

"get a bounded message queue with a balancing bounded dispatcher" in {
checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("balancing-bounded-dispatcher"),
Props[QueueReportingActor]().withDispatcher("balancing-bounded-dispatcher"),
"bounded-balancing",
BoundedMailboxTypes)
}

"get a bounded message queue with a requiring balancing bounded dispatcher" in {
checkMailboxQueue(
Props[QueueReportingActor].withDispatcher("requiring-balancing-bounded-dispatcher"),
Props[QueueReportingActor]().withDispatcher("requiring-balancing-bounded-dispatcher"),
"requiring-bounded-balancing",
BoundedMailboxTypes)
}
Expand Down
Loading

0 comments on commit ea7205e

Please sign in to comment.