Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import pekko.util.Timeout

object TestProducerWithAsk {

trait Command
sealed trait Command
final case class RequestNext(askTo: ActorRef[ProducerController.MessageWithConfirmation[TestConsumer.Job]])
extends Command
private case object Tick extends Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import pekko.actor.typed.scaladsl.Behaviors

object TestProducerWorkPulling {

trait Command
sealed trait Command
final case class RequestNext(sendTo: ActorRef[TestConsumer.Job]) extends Command
private case object Tick extends Command

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ object EventStreamDocSpec {
case UnhandledMessage(message, sender, recipient) =>
context.log.info("UnhandledMessage received from sender ({}) to recipient ({}) with message: {}",
sender.path.name, recipient.path.name, message.toString)

case other =>
context.log.warn("Unexpected AllDeadLetters: {}", other)
}
Behaviors.same
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private[pekko] object Collections {
pf.applyOrElse(t, NotApplied) match {
case _: NotApplied.type => // do nothing
case r: R @unchecked => builder += r
case _ => // unreachable, NotApplied handled above, everything else is R
}
})
builder.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import pekko.actor.typed.scaladsl.Behaviors
import com.typesafe.config.ConfigFactory

object Producer {
trait Command
sealed trait Command

case object Run extends Command
private case class WrappedRequestNext(r: ProducerController.RequestNext[Consumer.Command]) extends Command
Expand Down Expand Up @@ -83,7 +83,7 @@ object Producer {
}

object Consumer {
trait Command
sealed trait Command

case object TheMessage extends Command

Expand Down Expand Up @@ -111,7 +111,7 @@ object Consumer {
}

object WorkPullingProducer {
trait Command
sealed trait Command

case object Run extends Command
private case class WrappedRequestNext(r: WorkPullingProducerController.RequestNext[Consumer.Command]) extends Command
Expand Down Expand Up @@ -148,7 +148,7 @@ object WorkPullingProducer {

object Guardian {

trait Command
sealed trait Command
final case class RunPointToPoint(id: String, numberOfMessages: Int, useAsk: Boolean, replyTo: ActorRef[Done])
extends Command
final case class RunWorkPulling(id: String, numberOfMessages: Int, workers: Int, replyTo: ActorRef[Done])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ object ShardedDaemonProcessSpec extends MultiNodeConfig {
case class ProcessActorEvent(id: Int, event: Any) extends CborSerializable

object ProcessActor {
trait Command
sealed trait Command
case object Stop extends Command

def apply(id: Int): Behavior[Command] = Behaviors.setup { ctx =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ object ShardingCompileOnlySpec {

// a sharded counter that sends responses to another sharded actor
object Counter {
trait Command
sealed trait Command
case object Increment extends Command
final case class GetValue(replyToEntityId: String) extends Command
val TypeKey: EntityTypeKey[Command] = EntityTypeKey[Command]("example-sharded-counter")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class ShardRegionDataTypesSpec extends AnyWordSpec with Matchers {
s match {
case ShardRegionStats(stats) =>
stats shouldBe Map("s1" -> 1)
case _ => fail("Should match ShardRegionStats")
}
}

Expand Down Expand Up @@ -103,6 +104,7 @@ class ShardRegionDataTypesSpec extends AnyWordSpec with Matchers {
state match {
case CurrentShardRegionState(shards) =>
shards shouldBe Set(ShardState("s1", Set("e1")))
case _ => fail("Should match CurrentShardRegionState")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CoordinatedActorShutdownSpec {
// #coordinated-shutdown-addTask
object MyActor {

trait Messages
sealed trait Messages
case class Stop(replyTo: ActorRef[Done]) extends Messages

def behavior: Behavior[Messages] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class SharedMutableStateDocSpec {
def expensiveCalculation(): Future[String] = ???

object MyActor {
trait Command
sealed trait Command
case class Message(msg: String, replyTo: ActorRef[Any]) extends Command
case class UpdateState(newState: String) extends Command

Expand Down
3 changes: 3 additions & 0 deletions docs/src/test/scala/typed/tutorial_4/DeviceGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

package typed.tutorial_4

import scala.annotation.nowarn

import org.apache.pekko.actor.typed.ActorRef
import org.apache.pekko.actor.typed.Behavior
import org.apache.pekko.actor.typed.PostStop
Expand Down Expand Up @@ -47,6 +49,7 @@ class DeviceGroup(context: ActorContext[DeviceGroup.Command], groupId: String)

context.log.info("DeviceGroup {} started", groupId)

@nowarn("msg=match may not be exhaustive")
override def onMessage(msg: Command): Behavior[Command] =
msg match {
case trackMsg @ RequestTrackDevice(`groupId`, deviceId, replyTo) =>
Expand Down
2 changes: 2 additions & 0 deletions docs/src/test/scala/typed/tutorial_5/DeviceGroup.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package typed.tutorial_5

import scala.annotation.nowarn
import scala.concurrent.duration._
import org.apache.pekko
import pekko.actor.typed.ActorRef
Expand Down Expand Up @@ -51,6 +52,7 @@ class DeviceGroup(context: ActorContext[DeviceGroup.Command], groupId: String)

context.log.info("DeviceGroup {} started", groupId)

@nowarn("msg=match may not be exhaustive")
override def onMessage(msg: Command): Behavior[Command] =
msg match {
// #query-added
Expand Down
2 changes: 2 additions & 0 deletions docs/src/test/scala/typed/tutorial_5/DeviceGroupQuery.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

package typed.tutorial_5

import scala.annotation.nowarn
import scala.concurrent.duration._

import org.apache.pekko
Expand Down Expand Up @@ -85,6 +86,7 @@ class DeviceGroupQuery(

// #query-outline
// #query-state
@nowarn("msg=match may not be exhaustive")
override def onMessage(msg: Command): Behavior[Command] =
msg match {
case WrappedRespondTemperature(response) => onRespondTemperature(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ object ReplicatedEventPublishingSpec {
val EntityType = "EventPublishingSpec"

object MyReplicatedBehavior {
trait Command
sealed trait Command
case class Add(text: String, replyTo: ActorRef[Done]) extends Command
case class Get(replyTo: ActorRef[Set[String]]) extends Command
case object Stop extends Command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ object RecoveryPermitterSpec {

object EventState extends State

trait Command
sealed trait Command

case object StopActor extends Command

Expand Down
3 changes: 1 addition & 2 deletions project/PekkoDisciplinePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ object PekkoDisciplinePlugin extends AutoPlugin {
"-Ywarn-nullary-override",
"-Ywarn-nullary-unit",
"-Ypartial-unification",
"-Yno-adapted-args") ++ Set(
"-Xlint:-strict-unsealed-patmat")
"-Yno-adapted-args")
case Some((2, 12)) =>
disciplineScalacOptions
case _ =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import pekko.util.OptionVal
// we got a pull but there is no open resource, we are either
// currently creating/restarting then the read will be triggered when creating the
// resource completes, or shutting down and then the pull does not matter anyway
case _ => // unreachable, OptionVal.Some and OptionVal.None cover all cases
}

override def postStop(): Unit = maybeResource match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ private[pekko] final class DropRepeated[T](predicate: (T, T) => Boolean) extends
case OptionVal.None =>
last = OptionVal.Some(elem)
push(out, last.get)
case _ => // unreachable, OptionVal.Some and OptionVal.None cover all cases
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ private[pekko] final case class GroupedAdjacentByWeighted[T, R](
} else {
pendingGroup = OptionVal.Some(group)
}
case _ => // unreachable, OptionVal.Some and OptionVal.None cover all cases
}

private def tryPullIfNeeded(): Unit = pendingGroup match {
Expand Down Expand Up @@ -182,6 +183,7 @@ private[pekko] final case class GroupedAdjacentByWeighted[T, R](
} else {
completeStage()
}
case _ => // unreachable
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ import pekko.util.OptionVal
else removeCurrentSource(completeIfClosed = true)
}
case OptionVal.None =>
case _ => // unreachable
}
}

Expand Down Expand Up @@ -123,6 +124,7 @@ import pekko.util.OptionVal
case OptionVal.Some(src) =>
src.cancel()
case OptionVal.None =>
case _ => // unreachable
}
}

Expand Down
Loading