Skip to content

fix: enable strict-unsealed-patmat lint and fix exhaustiveness warnings#3330

Merged
He-Pin merged 2 commits into
mainfrom
worktree-fix-exhaustive-patmat-265
Jul 14, 2026
Merged

fix: enable strict-unsealed-patmat lint and fix exhaustiveness warnings#3330
He-Pin merged 2 commits into
mainfrom
worktree-fix-exhaustive-patmat-265

Conversation

@He-Pin

@He-Pin He-Pin commented Jul 11, 2026

Copy link
Copy Markdown
Member

Motivation

Issue #265 tracks re-enabling the strict-unsealed-patmat lint that was disabled globally in #264 to unblock the build. This lint catches pattern matches on non-sealed traits that may not be exhaustive, a class of bugs that should be caught at compile time.

Modification

Remove the -Xlint:-strict-unsealed-patmat silencing flag from PekkoDisciplinePlugin for Scala 2.13 and fix all resulting exhaustiveness warnings across the codebase:

  • Seal traits where all subtypes are defined in the same file (test/doc specs, bench-jmh)
  • Add @nowarn annotations where traits are intentionally non-sealed for cross-file protocols (tutorials 4 & 5: DeviceGroup.Command, DeviceGroupQuery.Command)
  • Add catch-all cases for matches on OptionVal and other extractor-only types (Collections, UnfoldResourceSourceAsync, DropRepeated, GroupedAdjacentByWeighted, Switch)
  • Add catch-all cases for matches on non-sealed final classes with custom unapply (ShardRegionStats, CurrentShardRegionState, AllDeadLetters)
  • Add catch-all case for getStageActor partial function in StageActorRefBenchmark (bench-jmh)

21 files changed across actor, stream, docs, test, and bench-jmh modules.

Result

The strict-unsealed-patmat lint is now active for Scala 2.13, catching future pattern match exhaustiveness issues at compile time. No behavioral changes to production code — all catch-all cases are unreachable and marked as such.

Tests

  • sbt "docs / Test / compile" — success, no exhaustiveness errors
  • sbt "bench-jmh / Compile / compile" — success, no exhaustiveness errors

References

Fixes #265

@He-Pin He-Pin marked this pull request as draft July 11, 2026 14:58
He-Pin added 2 commits July 14, 2026 12:17
Motivation:
The strict-unsealed-patmat lint was disabled globally in #264 to unblock
the build, leaving many pattern matches on non-sealed traits unchecked.
Issue #265 tracks re-enabling this lint.

Modification:
Remove the -Xlint:-strict-unsealed-patmat silencing flag from
PekkoDisciplinePlugin for Scala 2.13. Fix all resulting exhaustiveness
warnings across the codebase:
- Seal Command traits where all subtypes are in the same file
- Add @nowarn annotations where traits are intentionally non-sealed
  (cross-file protocols in tutorials)
- Add catch-all cases for matches on OptionVal and other extractor-only
  types (Collections, stream operators)

Result:
The strict-unsealed-patmat lint is now active for Scala 2.13, catching
future pattern match exhaustiveness issues at compile time.

Tests:
sbt "docs / Test / compile" — success, no exhaustiveness errors

References:
Fixes #265
Motivation:
The strict-unsealed-patmat lint enabled in the previous commit caught
a non-exhaustive pattern match in bench-jmh's StageActorRefBenchmark
that was missed in the initial pass.

Modification:
Add a catch-all case to the getStageActor partial function in
StageActorSink.preStart to handle unexpected messages.

Result:
bench-jmh compiles without exhaustiveness warnings under
strict-unsealed-patmat.

Tests:
sbt "bench-jmh / Compile / compile" — success

References:
Refs #265
@He-Pin He-Pin force-pushed the worktree-fix-exhaustive-patmat-265 branch from 5f5c838 to b2622b1 Compare July 14, 2026 04:32
@He-Pin He-Pin marked this pull request as ready for review July 14, 2026 04:35
@He-Pin He-Pin added this to the 2.0.0-M4 milestone Jul 14, 2026

@pjfanning pjfanning left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@He-Pin He-Pin merged commit b936e5e into main Jul 14, 2026
10 checks passed
@He-Pin He-Pin deleted the worktree-fix-exhaustive-patmat-265 branch July 14, 2026 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Investigate fixing exhaustive match issues in Pekko codebase

2 participants