He-Pin opened a new pull request, #3065:
URL: https://github.com/apache/pekko/pull/3065
### Motivation
The codebase needs to compile with both Scala 3.3.x (current production) and
Scala 3.8.4 (forward compatibility for the upcoming 3.9 LTS). Several patterns
in the codebase break under Scala 3.8 due to changes in how context bounds are
desugared (they become `using` clauses), stricter deprecation warnings, and
syntax changes.
### Modification
170 files changed across the codebase:
- **ClassTag context bound fixes**: In Scala 3.8, `[T: ClassTag]` desugars
to a `using` clause, making explicit `ClassTag` passing
positional-incompatible. Fixed by using `implicit val ct: ClassTag[T] =
ClassTag(clazz)` in scope and relying on implicit resolution instead of
explicit passing. Key files: `PersistencePlugin.scala`,
`EventSourcedBehaviorTestKit.scala`, `ActorContextSpec.scala`,
`BehaviorTestKitSpec.scala`, `Behavior.scala`, `EventStream.scala`,
`Topic.scala`, `ShardingProducerController.scala`,
`ShardedDaemonProcessImpl.scala`, `StreamTestKit.scala`.
- **PersistencePlugin implicit parameter merge**: Merged `[T: ClassTag]`
context bound and `(implicit ev: PluginProvider[...])` into a single `implicit`
parameter list `(implicit ct: ClassTag[T], ev: PluginProvider[T, ScalaDsl,
JavaDsl])` to avoid context bound + separate implicit parameter mismatch in
Scala 3.8.
- **`.apply()` trick**: Used `decoration[T].apply(behavior)` instead of
`decoration[T](behavior)` to separate implicit resolution from function
application (Scala 2.13 interprets `(behavior)` as the implicit ClassTag
argument).
- **`private[this]` → `private`**: Scala 3.8 deprecates `private[this]` in
favor of `private`.
- **`= _` initializers → explicit defaults**: Replaced `= _` with `= null`,
`= None`, `= 0`, etc. as Scala 3.8 deprecates uninitialized vars.
- **`SortedSet.empty(ordering)` fix**: Bound ordering as `implicit val ord`
before calling `.empty[Member]` to avoid implicit resolution issues.
- **`@unchecked` annotations**: Added for type-test patterns that can't be
checked at runtime under Scala 3.
- **`@nowarn` filters**: Used message-based `@nowarn("msg=never used")`
instead of category-based filters for cross-version compatibility.
- **`PekkoDisciplinePlugin.scala`**: Added `-Wconf` suppression rules for
Scala 3.8 deprecation/syntax warnings in both main and test scopes.
- **No `using` keyword in shared sources**: All changes use cross-compatible
patterns (`implicit val`, `.apply()` trick). The `using` keyword only appears
in `scala-3/` directories.
### Result
All modules compile with both Scala 2.13.18 and Scala 3.8.4. Production
Scala 3 version remains at 3.3.8 — this change only ensures forward
compatibility. No behavioral changes to the runtime.
### Tests
- `sbt "++3.8.4" "Test / compile"` — success across all modules
- `sbt "Test / compile"` (Scala 2.13.18) — success across all modules
### References
Supersedes #3060 (rebased onto main to resolve Hub.scala conflict with
#3063).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]