This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new ce8e081a0b fix: fix compilation warnings across Scala 2.13 and 3.3
cross-builds (#3297)
ce8e081a0b is described below
commit ce8e081a0b0d359dcfdc38e15561df1a500b806d
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Mon Jul 6 17:14:06 2026 +0800
fix: fix compilation warnings across Scala 2.13 and 3.3 cross-builds (#3297)
Motivation:
Several deprecation and pattern match warnings were present across the
codebase, including @SerialVersionUID on traits (Scala 3 warning text
changed), unchecked type tests, unreachable cases, and invalid @nowarn
filters.
Modification:
- Update @nowarn message filters for @SerialVersionUID to use broader
regex matching both Scala 3.3 "does nothing" and older "has no effect"
- Add @unchecked to type tests that can't be checked at runtime
(ByteString, AskPattern)
- Fix unreachable case in TlsGraphStage (sealed trait match)
- Fix invalid @nowarn filter in bench-jmh benchmark
- Update boilerplate template for generated Functions.scala
Result:
Clean compilation with zero warnings on both Scala 2.13.18 and 3.3.8
with -Dpekko.allwarnings=true.
Tests:
sbt -Dpekko.allwarnings=true "+test:compile" - passes with no warnings
References:
None - code quality improvement
---
.../org/apache/pekko/actor/typed/scaladsl/AskPattern.scala | 4 ++--
.../apache/pekko/japi/function/Functions.scala.template | 4 ++--
.../src/main/scala/org/apache/pekko/actor/ActorPath.scala | 2 +-
.../main/scala/org/apache/pekko/actor/ActorSelection.scala | 2 +-
actor/src/main/scala/org/apache/pekko/actor/Deployer.scala | 6 +++---
.../scala/org/apache/pekko/japi/function/Function.scala | 14 +++++++-------
.../main/scala/org/apache/pekko/routing/Balancing.scala | 2 +-
.../main/scala/org/apache/pekko/routing/Broadcast.scala | 2 +-
actor/src/main/scala/org/apache/pekko/routing/Random.scala | 2 +-
.../main/scala/org/apache/pekko/routing/RoundRobin.scala | 2 +-
.../main/scala/org/apache/pekko/routing/RouterConfig.scala | 6 +++---
.../scala/org/apache/pekko/routing/SmallestMailbox.scala | 4 ++--
.../src/main/scala/org/apache/pekko/util/ByteString.scala | 4 ++--
.../pekko/stream/AsyncBoundaryThroughputBenchmark.scala | 2 +-
.../org/apache/pekko/remote/RemotingLifecycleEvent.scala | 4 ++--
.../org/apache/pekko/stream/impl/io/TlsGraphStage.scala | 4 ++--
16 files changed, 32 insertions(+), 32 deletions(-)
diff --git
a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/AskPattern.scala
b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/AskPattern.scala
index 0c811f764b..1fff9cc5b9 100644
---
a/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/AskPattern.scala
+++
b/actor-typed/src/main/scala/org/apache/pekko/actor/typed/scaladsl/AskPattern.scala
@@ -119,8 +119,8 @@ object AskPattern {
// We do not currently use the implicit scheduler, but want to require it
// because it might be needed when we move to a 'native' typed runtime,
see #24219
ref match {
- case a: InternalRecipientRef[Req] => askClassic[Req, Res](a, timeout,
replyTo)
- case a =>
+ case a: (InternalRecipientRef[Req] @unchecked) => askClassic[Req,
Res](a, timeout, replyTo)
+ case a =>
throw new IllegalStateException(
"Only expect references to be RecipientRef, ActorRefAdapter or
ActorSystemAdapter until " +
"native system is implemented: " + a.getClass)
diff --git
a/actor/src/main/boilerplate/org/apache/pekko/japi/function/Functions.scala.template
b/actor/src/main/boilerplate/org/apache/pekko/japi/function/Functions.scala.template
index d78d1783ac..35bd3dea03 100644
---
a/actor/src/main/boilerplate/org/apache/pekko/japi/function/Functions.scala.template
+++
b/actor/src/main/boilerplate/org/apache/pekko/japi/function/Functions.scala.template
@@ -19,7 +19,7 @@ import scala.annotation.nowarn
* A Function interface. Used to create 1-arg first-class-functions is Java.
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(##1L)
@FunctionalInterface
trait Function1[[#-T1#], +R] extends java.io.Serializable {
@@ -34,7 +34,7 @@ trait Function1[[#-T1#], +R] extends java.io.Serializable {
* A Procedure is like a Function, but it doesn't produce a return value.
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(##1L)
@FunctionalInterface
trait Procedure1[[#-T1#]] extends java.io.Serializable {
diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala
b/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala
index 91dcd6b424..d52602cc83 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/ActorPath.scala
@@ -171,7 +171,7 @@ object ActorPath {
* references are compared the unique id of the actor is not taken into account
* when comparing actor paths.
*/
-@nowarn("msg=@SerialVersionUID has no effect on traits")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
sealed trait ActorPath extends Comparable[ActorPath] with Serializable {
diff --git a/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala
b/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala
index dbb5b439ad..7facfe2e65 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/ActorSelection.scala
@@ -307,7 +307,7 @@ private[pekko] final case class ActorSelectionMessage(
/**
* INTERNAL API
*/
-@nowarn("msg=@SerialVersionUID has no effect on traits")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
private[pekko] sealed trait SelectionPathElement
diff --git a/actor/src/main/scala/org/apache/pekko/actor/Deployer.scala
b/actor/src/main/scala/org/apache/pekko/actor/Deployer.scala
index 9a9394bb58..deb8b89133 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/Deployer.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/Deployer.scala
@@ -182,7 +182,7 @@ trait Scope {
def withFallback(other: Scope): Scope
}
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
abstract class LocalScope extends Scope
@@ -191,7 +191,7 @@ abstract class LocalScope extends Scope
* which do not set a different scope. It is also the only scope handled by
* the LocalActorRefProvider.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
case object LocalScope extends LocalScope {
@@ -206,7 +206,7 @@ case object LocalScope extends LocalScope {
/**
* This is the default value and as such allows overrides.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
abstract class NoScopeGiven extends Scope
@SerialVersionUID(1L)
diff --git a/actor/src/main/scala/org/apache/pekko/japi/function/Function.scala
b/actor/src/main/scala/org/apache/pekko/japi/function/Function.scala
index 1a5c03ad40..ec22aed804 100644
--- a/actor/src/main/scala/org/apache/pekko/japi/function/Function.scala
+++ b/actor/src/main/scala/org/apache/pekko/japi/function/Function.scala
@@ -22,7 +22,7 @@ import org.apache.pekko.util.ConstantFun
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.Function` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Function[-T, +R] extends java.io.Serializable {
@@ -56,7 +56,7 @@ object Function {
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.BiFunction` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Function2[-T1, -T2, +R] extends java.io.Serializable {
@@ -79,7 +79,7 @@ trait Function2[-T1, -T2, +R] extends java.io.Serializable {
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.Consumer` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Procedure[-T] extends java.io.Serializable {
@@ -92,7 +92,7 @@ trait Procedure[-T] extends java.io.Serializable {
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.Effect` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Effect extends java.io.Serializable {
@@ -106,7 +106,7 @@ trait Effect extends java.io.Serializable {
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.Predicate` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Predicate[-T] extends java.io.Serializable {
@@ -124,7 +124,7 @@ trait Predicate[-T] extends java.io.Serializable {
* `Serializable` is needed to be able to grab line number for Java 8 lambdas.
* Supports throwing `Exception` in the apply, which the
`java.util.function.BiPredicate` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Predicate2[-T1, -T2] extends java.io.Serializable {
@@ -141,7 +141,7 @@ trait Predicate2[-T1, -T2] extends java.io.Serializable {
* A constructor/factory, takes no parameters but creates a new value of type
T every call.
* Supports throwing `Exception` in the create method, which the
`java.util.function.Supplier` counterpart does not.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@FunctionalInterface
trait Creator[+T] extends Serializable {
diff --git a/actor/src/main/scala/org/apache/pekko/routing/Balancing.scala
b/actor/src/main/scala/org/apache/pekko/routing/Balancing.scala
index f87a0e40d0..309001dd4b 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/Balancing.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/Balancing.scala
@@ -38,7 +38,7 @@ private[pekko] object BalancingRoutingLogic {
* INTERNAL API
* Selects the first routee, balancing will be done by the dispatcher.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
private[pekko] final class BalancingRoutingLogic extends RoutingLogic {
override def select(message: Any, routees: immutable.IndexedSeq[Routee]):
Routee =
diff --git a/actor/src/main/scala/org/apache/pekko/routing/Broadcast.scala
b/actor/src/main/scala/org/apache/pekko/routing/Broadcast.scala
index b94496205a..191e070e50 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/Broadcast.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/Broadcast.scala
@@ -31,7 +31,7 @@ object BroadcastRoutingLogic {
/**
* Broadcasts a message to all its routees.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
final class BroadcastRoutingLogic extends RoutingLogic {
override def select(message: Any, routees: immutable.IndexedSeq[Routee]):
Routee =
diff --git a/actor/src/main/scala/org/apache/pekko/routing/Random.scala
b/actor/src/main/scala/org/apache/pekko/routing/Random.scala
index 4603f09584..451e74888c 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/Random.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/Random.scala
@@ -33,7 +33,7 @@ object RandomRoutingLogic {
/**
* Randomly selects one of the target routees to send a message to
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
final class RandomRoutingLogic extends RoutingLogic {
override def select(message: Any, routees: immutable.IndexedSeq[Routee]):
Routee =
diff --git a/actor/src/main/scala/org/apache/pekko/routing/RoundRobin.scala
b/actor/src/main/scala/org/apache/pekko/routing/RoundRobin.scala
index df967371fd..7d06eefe08 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/RoundRobin.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/RoundRobin.scala
@@ -34,7 +34,7 @@ object RoundRobinRoutingLogic {
* Uses round-robin to select a routee. For concurrent calls,
* round robin is just a best effort.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
final class RoundRobinRoutingLogic extends RoutingLogic {
val next = new AtomicLong
diff --git a/actor/src/main/scala/org/apache/pekko/routing/RouterConfig.scala
b/actor/src/main/scala/org/apache/pekko/routing/RouterConfig.scala
index d3b96fdeb4..db84b801e2 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/RouterConfig.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/RouterConfig.scala
@@ -47,7 +47,7 @@ import pekko.japi.Util.immutableSeq
* someone tries sending a message to that reference before the constructor of
* RoutedActorRef has returned, there will be a `NullPointerException`!
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
trait RouterConfig extends Serializable {
@@ -384,7 +384,7 @@ case object NoRouter extends NoRouter {
/**
* INTERNAL API
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
private[pekko] trait RouterManagementMesssage
@@ -393,7 +393,7 @@ private[pekko] trait RouterManagementMesssage
* A [[Routees]] message is sent asynchronously to the "requester" containing
information
* about what routees the router is routing over.
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
abstract class GetRoutees extends RouterManagementMesssage
diff --git
a/actor/src/main/scala/org/apache/pekko/routing/SmallestMailbox.scala
b/actor/src/main/scala/org/apache/pekko/routing/SmallestMailbox.scala
index 13b9abb7ea..6485704d79 100644
--- a/actor/src/main/scala/org/apache/pekko/routing/SmallestMailbox.scala
+++ b/actor/src/main/scala/org/apache/pekko/routing/SmallestMailbox.scala
@@ -43,7 +43,7 @@ object SmallestMailboxRoutingLogic {
* since their mailbox size is unknown</li>
* </ul>
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
class SmallestMailboxRoutingLogic extends RoutingLogic {
override def select(message: Any, routees: immutable.IndexedSeq[Routee]):
Routee =
@@ -189,7 +189,7 @@ class SmallestMailboxRoutingLogic extends RoutingLogic {
* @param routerDispatcher dispatcher to use for the router head actor, which
handles
* supervision, death watch and router management messages
*/
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
final case class SmallestMailboxPool(
nrOfInstances: Int,
diff --git a/actor/src/main/scala/org/apache/pekko/util/ByteString.scala
b/actor/src/main/scala/org/apache/pekko/util/ByteString.scala
index cba7f0d9e5..e835387dd8 100644
--- a/actor/src/main/scala/org/apache/pekko/util/ByteString.scala
+++ b/actor/src/main/scala/org/apache/pekko/util/ByteString.scala
@@ -2849,7 +2849,7 @@ final class ByteStringBuilder extends Builder[Byte,
ByteString] {
case bs: ByteString => addAll(bs)
case xs: WrappedArray.ofByte =>
if (xs.nonEmpty) putByteArrayUnsafe(xs.array.clone)
- case seq: collection.IndexedSeq[Byte] if shouldResizeTempFor(seq.length)
=>
+ case seq: (collection.IndexedSeq[Byte] @unchecked) if
shouldResizeTempFor(seq.length) =>
if (seq.nonEmpty) {
val copied = Array.from(xs)
@@ -2857,7 +2857,7 @@ final class ByteStringBuilder extends Builder[Byte,
ByteString] {
_builder += ByteString.ByteString1(copied)
_length += seq.length
}
- case seq: collection.IndexedSeq[Byte] =>
+ case seq: (collection.IndexedSeq[Byte] @unchecked) =>
if (seq.nonEmpty) {
ensureTempSize(_tempLength + seq.size)
seq.copyToArray(_temp, _tempLength)
diff --git
a/bench-jmh/src/main/scala/org/apache/pekko/stream/AsyncBoundaryThroughputBenchmark.scala
b/bench-jmh/src/main/scala/org/apache/pekko/stream/AsyncBoundaryThroughputBenchmark.scala
index b93ec299ca..19b14ea4af 100644
---
a/bench-jmh/src/main/scala/org/apache/pekko/stream/AsyncBoundaryThroughputBenchmark.scala
+++
b/bench-jmh/src/main/scala/org/apache/pekko/stream/AsyncBoundaryThroughputBenchmark.scala
@@ -92,7 +92,7 @@ class JitSafeCompletionLatchInt extends
GraphStageWithMaterializedValue[SinkShap
val in = Inlet[Int]("JitSafeCompletionLatchInt.in")
override val shape = SinkShape(in)
- @nowarn("cat=unused-params")
+ @nowarn("msg=never used")
override def createLogicAndMaterializedValue(inheritedAttributes:
Attributes): (GraphStageLogic, CountDownLatch) = {
val latch = new CountDownLatch(1)
val logic = new GraphStageLogic(shape) with InHandler {
diff --git
a/remote/src/main/scala/org/apache/pekko/remote/RemotingLifecycleEvent.scala
b/remote/src/main/scala/org/apache/pekko/remote/RemotingLifecycleEvent.scala
index 751885bba6..d7fe18b139 100644
--- a/remote/src/main/scala/org/apache/pekko/remote/RemotingLifecycleEvent.scala
+++ b/remote/src/main/scala/org/apache/pekko/remote/RemotingLifecycleEvent.scala
@@ -20,14 +20,14 @@ import pekko.actor.{ ActorSystem, Address }
import pekko.event.{ Logging, LoggingAdapter }
import pekko.event.Logging.LogLevel
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@deprecated("Classic remoting is deprecated, use Artery", "Akka 2.6.0")
sealed trait RemotingLifecycleEvent extends Serializable {
def logLevel: Logging.LogLevel
}
-@nowarn("msg=@SerialVersionUID has no effect")
+@nowarn("msg=@SerialVersionUID (has no effect|does nothing)")
@SerialVersionUID(1L)
@deprecated("Classic remoting is deprecated, use Artery", "Akka 2.6.0")
sealed trait AssociationEvent extends RemotingLifecycleEvent {
diff --git
a/stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala
b/stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala
index f700db110b..65e3a9110c 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/impl/io/TlsGraphStage.scala
@@ -838,8 +838,8 @@ import pekko.util.ByteString
}
continue = false
- case other =>
- throw new IllegalArgumentException(s"Unexpected TLS input
element: $other")
+ case null =>
+ throw new IllegalArgumentException(s"Unexpected TLS input
element: null")
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]