Skip to content

chore: remove leftover Scala 2.12 idioms - #3539

Open
pjfanning wants to merge 5 commits into
apache:mainfrom
pjfanning:scala-2.13-idioms
Open

pjfanning wants to merge 5 commits into
apache:mainfrom
pjfanning:scala-2.13-idioms

Conversation

@pjfanning

@pjfanning pjfanning commented Sep 12, 2026

Copy link
Copy Markdown
Member

Motivation

The codebase still carried a number of Scala 2.12-era idioms that are redundant or deprecated on Scala 2.13/3: immutable.Seq qualifiers (scala.Seq has been immutable.Seq since 2.13), the deprecated mutable.WrappedArray alias, filterKeys/mapValues on Map, Either left/right projections, and .toIterator/Stream in user-facing doc snippets.

Modification

  • Replace immutable.Seq with Seq across ~210 files and drop the now-unused scala.collection.immutable imports. scala.Seq is a type alias for scala.collection.immutable.Seq on 2.13 and 3, so this is source- and binary-compatible (same erasure). DslFactoriesConsistencySpec is left as-is since it deliberately distinguishes collection.Seq from immutable.Seq.
  • ByteStringBuilder.addAll: match mutable.ArraySeq.ofByte and immutable.ArraySeq.ofByte instead of the deprecated WrappedArray.ofByte. Array.toSeq/toIndexedSeq produce immutable.ArraySeq.ofByte on 2.13, which previously fell through to the generic path.
  • Remove a dead commented-out CanBuildFrom block in ByteString.
  • ManifestInfo: replace deprecated filterKeys (and its @nowarn) with filter.
  • ShardRegion scaladoc example: filterKeys -> filter.
  • Rendered doc snippets: Source(Stream.from(1)) -> Source(LazyList.from(1)) (KillSwitchDocSpec), buffer.toIterator -> buffer.iterator (GraphStageDocSpec).
  • Tests: Shrink.withLazyList instead of Shrink(_ => Stream.empty), view.mapValues instead of a @nowarn wrapper, .iterator instead of .toIterator, and plain Either equality instead of .left.get/.right.get (dropping the @nowarn on MetricNumericConverterSpec).
  • Paradox docs: prose and @apidoc scala anchors updated from immutable.Seq to Seq to match the regenerated scaladoc ids (all 25 Seq-bearing anchors verified against stream/doc output); four anchors that were already broken on main were corrected while touching them.
  • MiMa: one IncompatibleSignatureProblem filter for Shape.hasOnePort (@InternalApi private[pekko]): erased descriptor is unchanged, only the Java generic signature moved from Seq<?> to Seq<Object>.

The 2.12 branches in project/PekkoDisciplinePlugin.scala and the filterKeys/mapValues uses under project/ (sbt still runs on 2.12) are intentionally left unchanged.

Result

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

Tests

  • native scalafmt run on all changed files
  • sbt stream/mimaReportBinaryIssues passes locally with the filter
  • sbt stream/doc generated and used to verify the paradox anchors
  • full Test/compile and tests: relying on CI

References

None - Scala 2.12 support was dropped previously

Motivation:
The codebase still carried a number of Scala 2.12-era idioms that are
redundant or deprecated on Scala 2.13/3: `immutable.Seq` qualifiers
(`scala.Seq` has been `immutable.Seq` since 2.13), the deprecated
`mutable.WrappedArray` alias, `filterKeys`/`mapValues` on `Map`,
`Either` left/right projections, `.toIterator` and `Stream` in
user-facing doc snippets.

Modification:
- Replace `immutable.Seq` with `Seq` and drop the now-unused
  `scala.collection.immutable` imports (same erasure, binary compatible).
- `ByteStringBuilder.addAll`: match `mutable.ArraySeq.ofByte` and
  `immutable.ArraySeq.ofByte` instead of the deprecated
  `WrappedArray.ofByte`; the immutable case previously fell through to
  the generic path.
- Remove a dead commented-out `CanBuildFrom` block in `ByteString`.
- `ManifestInfo`: replace deprecated `filterKeys` with `filter`.
- `ShardRegion` scaladoc example: `filterKeys` -> `filter`.
- Doc snippets: `Stream.from(1)` -> `LazyList.from(1)`,
  `buffer.toIterator` -> `buffer.iterator`.
- Tests: `Shrink.withLazyList`, `view.mapValues`, `.iterator`, and
  plain `Either` equality instead of `.left.get`/`.right.get`.

Result:
No remaining 2.12 collection idioms in source and doc code. Build
definition under `project/` is intentionally left unchanged.

Tests:
- native scalafmt run on changed files
- sbt Test/compile, multi-jvm:compile in progress; relying on CI

References:
None - Scala 2.12 support was dropped previously
@pjfanning
pjfanning marked this pull request as draft September 12, 2026 02:05
…-> Seq

Scaladoc now renders the rewritten signatures as `Seq[...]`, so the
`@apidoc` scala anchors in the stream operator pages no longer matched
the generated ids. Also fixes a few anchors that were already wrong
(missing `[T]`, `,M` vs `_`, short vs qualified names, and
`mergePrioritizedN` pointing at `Source` instead of `Source$`).
@pjfanning
pjfanning marked this pull request as ready for review September 12, 2026 08:20
pjfanning added a commit to apache/pekko-http that referenced this pull request Sep 12, 2026
…1298)

Motivation:
The codebase still carried the Scala 2.12-era `immutable.Seq` qualifier
across ~100 files. `scala.Seq` has been an alias for
`scala.collection.immutable.Seq` since 2.13, so the qualifier and the
`scala.collection.immutable` imports that only exist to support it are
redundant. Mirrors apache/pekko#3539.

Modification:
- Replace `immutable.Seq`, `collection.immutable.Seq` and
  `scala.collection.immutable.Seq` with `Seq` in main, test, multi-jvm
  and docs-snippet Scala sources.
- Drop `import scala.collection.immutable` / `immutable.Seq` where no
  other `immutable.*` member is used; keep it where TreeMap,
  VectorBuilder, ListMap, etc. are still referenced.
- `Http2Blueprint`: `import scala.collection.{ immutable, mutable }` ->
  `import scala.collection.mutable`.
- Paradox docs: prose and signature mentions updated from
  `immutable.Seq` to `Seq`; `alphabetically.md` table rows re-padded.
- Java sources are unchanged: `scala.Seq` is a package-object alias
  that Java cannot name.

Result:
No remaining `immutable.Seq` idioms in Scala sources or docs. Source-
and binary-compatible (same erasure); no MiMa filter needed.

Tests:
- native scalafmt 3.7.17 on all changed Scala files
- sbt Test/compile multi-jvm:compile (Scala 2.13.18)
- sbt http-core/mimaReportBinaryIssues http/mimaReportBinaryIssues
  http-cors/mimaReportBinaryIssues http-xml/mimaReportBinaryIssues
- sbt http-cors/test; HeaderSpec, HttpHeaderSpec, FramingSpec,
  Http2FramingSpec, HttpMessageRenderingSpec, Http*DetailedStringExampleSpec

References:
None - follows apache/pekko#3539
pjfanning added a commit to apache/pekko-management that referenced this pull request Sep 12, 2026
Motivation:
The codebase still carried the Scala 2.12-era immutable.Seq qualifier
(and its scala.collection.immutable / immutable.Seq imports). On Scala
2.13 and 3, scala.Seq is already an alias for
scala.collection.immutable.Seq, so the qualifier is redundant.

Modification:
Replace immutable.Seq with Seq across 24 files and drop the now-unused
scala.collection.immutable, scala.collection.immutable.Seq and
scala.collection.{ immutable => im } imports. Files that still use other
immutable.* types (Set, Iterable, SortedSet) keep the import.
ClusterHttpManagementRoutesSpec swaps its scala.collection.immutable._
wildcard for an explicit SortedSet import. ConsulServiceDiscovery drops
a redundant scala.collection.immutable.Seq(targets: _*) copy since
targets is already an immutable Seq.

Result:
No remaining Scala 2.12 collection idioms in main or test sources.
Source- and binary-compatible: same erasure, MiMa passes unchanged.

Tests:
- native scalafmt --mode diff-ref=upstream/main
- sbt +Test/compile (Scala 2.13, 3.3, 3.next) passes
- sbt mimaReportBinaryIssues on all touched modules passes
- sbt test on all touched modules passes (ConsulDiscoverySpec not run:
  requires Docker/testcontainers locally)

References:
None - equivalent of apache/pekko#3539
pjfanning added a commit to apache/pekko-connectors-kafka that referenced this pull request Sep 13, 2026
Motivation:
The codebase still carried Scala 2.12-era `immutable.Seq` qualifiers.
Since Scala 2.13, `scala.Seq` is a type alias for
`scala.collection.immutable.Seq`, so the qualifier is redundant.
Equivalent of apache/pekko#3539.

Modification:
- Replace `immutable.Seq` with `Seq` in main, testkit, test and doc
  sources and drop the now-unused `scala.collection.immutable` imports.
- Files that still use other `immutable.*` types keep the import.

Result:
No remaining `immutable.Seq` qualifiers. Source and binary compatible:
`Seq` erases to the same `scala.collection.immutable.Seq` class.

Tests:
- native `scalafmt` run on all changed files (no changes)
- `sbt Test/compile` passes
- `sbt core/mimaReportBinaryIssues testkit/mimaReportBinaryIssues` pass
- `sbt "tests/testOnly ...CommittingProducerSinkSpec ...ConsumerSpec"` pass

References:
None - Scala 2.12 support was dropped previously; port of apache/pekko#3539
pjfanning added a commit to apache/pekko-persistence-jdbc that referenced this pull request Sep 13, 2026
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 added a commit to apache/pekko-persistence-cassandra that referenced this pull request Sep 13, 2026
Motivation:
The codebase still carried Scala 2.12-era `immutable.Seq` qualifiers,
which are redundant on Scala 2.13/3 where `scala.Seq` is already an
alias for `scala.collection.immutable.Seq`. Mirrors apache/pekko#3539.

Modification:
- Replace `immutable.Seq` with `Seq` and drop the now-unused
  `scala.collection.immutable` / `immutable.Seq` imports.
- `MultiNodeClusterSpec.assertLeader`: pass the varargs `Seq` straight
  through instead of `.to[immutable.Seq]`.
- `immutable.Iterable` in `CassandraReadJournal` and `immutable.Queue`
  in `AllPersistenceIdsStage` are left as-is (no `scala.` alias).

Result:
No remaining Scala 2.12 collection idioms in main, test or multi-jvm
sources. Same erasure, so source- and binary-compatible.

Tests:
- native `scalafmt --mode diff-ref=upstream/main`: clean
- `sbt "+core/Test/compile"` (2.13.18 and 3.3.8): passes after clean
- `sbt core/mimaReportBinaryIssues` on 2.13.18 and 3.3.8: no issues
- `sbt checkCodeStyle`: passes
- `core/MultiJvm/compile` already fails on `main` for unrelated reasons
  (missing `FlightRecordingSupport`, `CassandraContainer` type params)
- Cassandra-backed test suites not run locally (no Docker); relying on CI

References:
None - equivalent of apache/pekko#3539
pjfanning added a commit to apache/pekko-projection that referenced this pull request Sep 13, 2026
Motivation:
The codebase still carried the Scala 2.12-era `immutable.Seq` qualifier
throughout main, test and doc sources. `scala.Seq` has been an alias for
`scala.collection.immutable.Seq` since Scala 2.13, so the qualifier and the
`scala.collection.immutable` imports that exist only to support it are
redundant. This mirrors apache/pekko#3539.

Modification:
- Replace `immutable.Seq` with `Seq` across 37 Scala files and drop the
  `scala.collection.immutable` imports that are no longer referenced
  (kept where `immutable.IndexedSeq`/`immutable.Set` are still used).
- Drop the explicit `import scala.collection.immutable.Seq` lines.
- Paradox prose (cassandra, jdbc, r2dbc, slick) updated from
  `immutable.Seq` to `Seq` to match the doc snippets.

The other idioms addressed upstream (`WrappedArray`, `filterKeys`/
`mapValues`, `Either` projections, `toIterator`, `Stream`) do not occur in
this repository.

Result:
No remaining Scala 2.12 collection idioms in main, test or doc sources.
Source- and binary-compatible: same type, same erasure.

Tests:
- native `scalafmt --mode diff-ref=upstream/main` run on changed files
- `sbt Test/compile jdbc-int-test/Test/compile r2dbc-int-test/Test/compile slick-int-test/Test/compile` passes on Scala 2.13 and 3.3
- `sbt core/mimaReportBinaryIssues jdbc/mimaReportBinaryIssues slick/mimaReportBinaryIssues cassandra/mimaReportBinaryIssues eventsourced/mimaReportBinaryIssues durable-state/mimaReportBinaryIssues r2dbc/mimaReportBinaryIssues` passes (grpc has MiMa disabled)
- `git diff --check` clean

References:
None - mirrors apache/pekko#3539; Scala 2.12 support was dropped previously
pjfanning added a commit to apache/pekko-connectors that referenced this pull request Sep 13, 2026
Motivation:
The codebase still qualified Seq as immutable.Seq throughout, a Scala
2.12-era habit. Since 2.13 (and on Scala 3) scala.Seq is an alias for
scala.collection.immutable.Seq, so the qualifier and the supporting
scala.collection.immutable imports are redundant. Mirrors apache/pekko#3539.

Modification:
- Replace immutable.Seq with Seq across 120 Scala files.
- Drop the now-unused scala.collection.immutable and
  scala.collection.immutable.Seq imports; reduce
  scala.collection.{ immutable, mutable } to scala.collection.mutable
  where only mutable remains in use.
- Keep scala.collection.immutable in files that still use
  immutable.Iterable, immutable.Map etc. immutable.Iterable is left
  unchanged because bare Iterable is scala.collection.Iterable.
- csv.md prose updated from immutable.Seq[String] to Seq[String].

Result:
No remaining immutable.Seq qualifiers in main, test or doc sources.
Types are identical (same erasure), so no API or binary change.

Tests:
- native scalafmt --mode diff-ref=origin/main
- sbt Test/compile (Scala 2.13.18) and sbt "++3.3.8" Test/compile
- sbt mimaReportBinaryIssues (all modules) passes, no filters needed
- sbt csv/test xml/test file/test text/test simple-codecs/test reference/test
- sbt docs/paradox

References:
None - follows apache/pekko#3539
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.

1 participant