Skip to content

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

Draft
He-Pin wants to merge 1 commit into
mainfrom
worktree-fix-exhaustive-patmat-265
Draft

fix: enable strict-unsealed-patmat lint and fix exhaustiveness warnings#3330
He-Pin wants to merge 1 commit 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)

20 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

References

Fixes #265

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
@He-Pin He-Pin marked this pull request as draft July 11, 2026 14:58
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

1 participant