Skip to content

Remove redundant Scala 2.12-era immutable.Seq imports - #617

Merged
pjfanning merged 1 commit into
apache:mainfrom
pjfanning:remove-scala212-idioms
Sep 13, 2026
Merged

pjfanning merged 1 commit into
apache:mainfrom
pjfanning:remove-scala212-idioms

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

Since Scala 2.13, scala.Seq is a type alias for scala.collection.immutable.Seq, and Set, Vector, Nil and friends in the scala package already refer to the immutable collections. The scala.collection.immutable imports and immutable.Seq qualifiers carried over from the Scala 2.12 days are therefore redundant now that this project only builds on 2.13 and 3.

This is the pekko-persistence-jdbc counterpart of apache/pekko#3539. Of the idioms cleaned up there, only the immutable.Seq one exists in this repo — there are no WrappedArray, filterKeys/mapValues, Either projection, Stream or .toIterator uses to touch.

Modification

  • Drop the now-unused scala.collection.immutable imports (immutable._, immutable.Seq, immutable.Set, immutable.{ Nil, Seq }, immutable.{ Seq, Vector }) across 23 files.
  • Replace immutable.Seq / scala.collection.immutable.Seq with plain Seq.
  • MissingElements keeps its immutable.NumericRange import since NumericRange is not aliased in scala._.

scala.Seq erases to the same class, so the binary shape is unchanged. The one place where dropping immutable._ changes a resolved type is a local def next(id: String): Iterable[String] inside JdbcReadJournal.persistenceIds (now collection.Iterable instead of immutable.Iterable), which is a closure-local helper passed to statefulMapConcat and not part of any API.

Result

No remaining Scala 2.12 collection idioms in main or test sources.

Tests

  • native scalafmt --mode diff-ref=upstream/main
  • sbt "+core/Test/compile" on Scala 2.13.18, 3.3.8 and 3.9.0
  • sbt core/mimaReportBinaryIssues passes (with mimaReportSignatureProblems := true)
  • sbt "core/Test/testOnly ...TrySeqTest ...BaseDaoSpec ...H2LimitWindowingStreamTest ...JdbcAsyncWriteJournalShutdownTest ...H2ScalaCurrentPersistenceIdsTest ...ByteArrayJournalSerializerTest": 16 tests, all passed against H2
  • git diff --check clean
  • No new directional test: this is a pure import/alias cleanup with no behavior change; the existing specs covering the touched code were run above.

References

Refs apache/pekko#3539

Motivation:
Since Scala 2.13, `scala.Seq` is a type alias for
`scala.collection.immutable.Seq`, and `Set`, `Vector`, `Nil` and
friends in the `scala` package already refer to the immutable
collections. The `scala.collection.immutable` imports and
`immutable.Seq` qualifiers carried over from the Scala 2.12 days are
therefore redundant now that this project only builds on 2.13 and 3.
This is the pekko-persistence-jdbc counterpart of apache/pekko#3539.

Modification:
- Drop the now-unused `scala.collection.immutable` imports
  (`immutable._`, `immutable.Seq`, `immutable.Set`,
  `immutable.{ Nil, Seq }`, `immutable.{ Seq, Vector }`).
- Replace `immutable.Seq` / `scala.collection.immutable.Seq` with
  plain `Seq`.
- `MissingElements` keeps its `immutable.NumericRange` import since
  `NumericRange` is not aliased in `scala._`.

`scala.Seq` erases to the same class, so the binary shape is unchanged.

Result:
No remaining Scala 2.12 collection idioms in main or test sources.

Tests:
- native `scalafmt --mode diff-ref=upstream/main`
- `sbt "+core/Test/compile"` on Scala 2.13.18, 3.3.8 and 3.9.0
- `sbt core/mimaReportBinaryIssues` passes (signature problems enabled)
- `sbt "core/Test/testOnly ...TrySeqTest ...BaseDaoSpec
  ...H2LimitWindowingStreamTest ...JdbcAsyncWriteJournalShutdownTest
  ...H2ScalaCurrentPersistenceIdsTest ...ByteArrayJournalSerializerTest"`:
  16 tests, all passed (H2)
- `git diff --check` clean

References:
Refs apache/pekko#3539
@pjfanning
pjfanning merged commit 9d93fbf into apache:main Sep 13, 2026
23 checks passed
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.

2 participants