This is an automated email from the ASF dual-hosted git repository.

He-Pin pushed a commit to branch scala3-upgrade-fix-warnings
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/scala3-upgrade-fix-warnings by 
this push:
     new 683f8740c3 fix: resolve Scala 2.13 CI failures on docs compilation and 
BehaviorTestKit
683f8740c3 is described below

commit 683f8740c3f43019c5aa708017cdb90e68d994d3
Author: He-Pin <[email protected]>
AuthorDate: Sun Jun 14 05:58:30 2026 +0800

    fix: resolve Scala 2.13 CI failures on docs compilation and BehaviorTestKit
    
    Motivation:
    PR #3060 CI was failing with two categories of errors on Scala 2.13:
    1. ~100 fatal warnings in docs/Test/compile from unused imports, locals,
       and pattern variables that were not suppressed
    2. "not found: type U" in BehaviorTestKitSpec due to type erasure in
       pattern matching
    
    Modification:
    - PekkoDisciplinePlugin: add docsScala2Suppressions with explicit -Wconf
      rules for each unused subcategory (unused-imports, unused-locals,
      unused-pat-vars, etc.) because Scala 2.13's -Wconf uses exact string
      matching, so cat=unused:s does not match subcategories
    - BehaviorTestKitSpec: revert ClassTag[U] change back to explicit
      ClassTag(messageClass) passing since U is not in scope during
      pattern matching of CreateMessageAdapter
    
    Result:
    docs/Test/compile and actor-testkit-typed/Test/compile pass on both
    Scala 2.13.18 and 3.3.8
    
    Tests:
    - sbt "++ 2.13.18 docs/Test/compile" — success (30 compilation units)
    - sbt "++ 3.3.8 docs/Test/compile" — success
    - sbt "++ 2.13.18 actor-testkit-typed/Test/compile" — success
    - sbt "++ 3.3.8 actor-testkit-typed/Test/compile" — success
    
    References:
    Fixes CI failures on PR #3060
---
 .../typed/scaladsl/BehaviorTestKitSpec.scala       |  3 +--
 project/PekkoDisciplinePlugin.scala                | 24 ++++++++++++++++++----
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala
 
b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala
index f7bd2df077..4f13e0d415 100644
--- 
a/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala
+++ 
b/actor-testkit-typed/src/test/scala/org/apache/pekko/actor/testkit/typed/scaladsl/BehaviorTestKitSpec.scala
@@ -126,8 +126,7 @@ object BehaviorTestKitSpec {
               replyTo ! Done
               Behaviors.same
             case CreateMessageAdapter(messageClass, f, replyTo) =>
-              implicit val ct: ClassTag[U] = ClassTag(messageClass)
-              val adaptor = context.messageAdapter(f)
+              val adaptor = context.messageAdapter(f)(ClassTag(messageClass))
               replyTo.foreach(_ ! adaptor.unsafeUpcast)
               Behaviors.same
             case Log(what) =>
diff --git a/project/PekkoDisciplinePlugin.scala 
b/project/PekkoDisciplinePlugin.scala
index ce9f38e896..9507c45715 100644
--- a/project/PekkoDisciplinePlugin.scala
+++ b/project/PekkoDisciplinePlugin.scala
@@ -110,6 +110,22 @@ object PekkoDisciplinePlugin extends AutoPlugin {
     "-Wconf:cat=deprecation:s",
     "-Wconf:cat=unchecked:s") ++ scala3Suppressions
 
+  // cat=unused:s does not match subcategories (unused-imports, unused-locals, 
etc.)
+  // in Scala 2.13's -Wconf category matching (exact string match, not 
hierarchical).
+  // Add explicit rules for each subcategory plus message-based patterns as 
fallback.
+  private val docsScala2Suppressions = Seq(
+    "-Wconf:cat=unused:s",
+    "-Wconf:cat=unused-imports:s",
+    "-Wconf:cat=unused-locals:s",
+    "-Wconf:cat=unused-pat-vars:s",
+    "-Wconf:cat=unused-params:s",
+    "-Wconf:cat=unused-privates:s",
+    "-Wconf:cat=unused-explicits:s",
+    "-Wconf:msg=Unused import:s",
+    "-Wconf:msg=is never used:s",
+    "-Wconf:cat=deprecation:s",
+    "-Wconf:cat=unchecked:s")
+
   /**
    * We are a little less strict in docs
    */
@@ -119,16 +135,16 @@ object PekkoDisciplinePlugin extends AutoPlugin {
       Compile / scalacOptions ++=
         (CrossVersion.partialVersion(scalaVersion.value).get match {
           case (3, _)  => scala3DocSuppressions
-          case (2, 13) => Seq("-Wconf:any:e", "-Wconf:cat=unused:s", 
"-Wconf:cat=deprecation:s", "-Wconf:cat=unchecked:s")
-          case (2, 12) => Seq("-Wconf:cat=unused:s", 
"-Wconf:cat=deprecation:s", "-Wconf:cat=unchecked:s", "-Wconf:any:e")
+          case (2, 13) => docsScala2Suppressions
+          case (2, 12) => docsScala2Suppressions :+ "-Wconf:any:e"
         }),
       Test / scalacOptions --= Seq("-Xlint", "-unchecked", "-deprecation"),
       Test / scalacOptions --= defaultScalaOptions.value,
       Test / scalacOptions ++=
         (CrossVersion.partialVersion(scalaVersion.value).get match {
           case (3, _)  => scala3DocSuppressions
-          case (2, 13) => Seq("-Wconf:any:e", "-Wconf:cat=unused:s", 
"-Wconf:cat=deprecation:s", "-Wconf:cat=unchecked:s")
-          case (2, 12) => Seq("-Wconf:cat=unused:s", 
"-Wconf:cat=deprecation:s", "-Wconf:cat=unchecked:s", "-Wconf:any:e")
+          case (2, 13) => "-Wconf:any:e" +: docsScala2Suppressions
+          case (2, 12) => docsScala2Suppressions :+ "-Wconf:any:e"
         }),
       Compile / doc / scalacOptions := Seq())
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to