Skip to content

chore: replace immutable.Seq with Seq, drop Scala 2.12-era imports - #1298

Merged
pjfanning merged 1 commit into
apache:mainfrom
pjfanning:scala-2.13-seq-idioms
Sep 12, 2026
Merged

pjfanning merged 1 commit into
apache:mainfrom
pjfanning:scala-2.13-seq-idioms

Conversation

@pjfanning

Copy link
Copy Markdown
Member

Motivation

The codebase still carried the Scala 2.12-era immutable.Seq qualifier across ~100 files. scala.Seq has been a type alias for scala.collection.immutable.Seq since 2.13, so the qualifier — and the scala.collection.immutable imports that exist only to support it — are redundant. This is the pekko-http counterpart of apache/pekko#3539.

Modification

  • Replace immutable.Seq, collection.immutable.Seq and scala.collection.immutable.Seq with Seq across main, test, multi-jvm and docs-snippet Scala sources (100 files).
  • Drop import scala.collection.immutable (70 files) and import scala.collection.immutable.Seq (13 files) where no other immutable.* member is used; the import is kept in the 16 files that still reference immutable.TreeMap, VectorBuilder, ListMap, IndexedSeq, etc.
  • Http2Blueprint: import scala.collection.{ immutable, mutable } -> import scala.collection.mutable.
  • Paradox docs (6 files): prose and signature mentions updated from immutable.Seq to Seq; the alphabetically.md table rows are re-padded so the columns stay aligned.
  • Java sources (Util.java, MediaTypes.java, RegexConverters.java) are deliberately unchanged: scala.Seq is a package-object alias that Java cannot name, so they must keep scala.collection.immutable.Seq.

The other idioms cleaned up in apache/pekko#3539 (WrappedArray, filterKeys/mapValues, .toIterator, Stream, .left.get/.right.get) do not occur in this repo — the existing mapValues/filterKeys calls already go through .view.

Result

No remaining immutable.Seq idioms in Scala sources or docs. The change is source- and binary-compatible (identical erasure); unlike the pekko PR, no MiMa filter was needed.

Tests

  • native scalafmt 3.7.17 run on all changed Scala files
  • sbt Test/compile multi-jvm:compile passes on Scala 2.13.18 (Scala 3 left to CI)
  • sbt http-core/mimaReportBinaryIssues http/mimaReportBinaryIssues http-cors/mimaReportBinaryIssues http-xml/mimaReportBinaryIssues — all pass against 1.0.0 with mimaReportSignatureProblems := true (testkit has MiMa disabled in the build)
  • sbt http-cors/test plus HeaderSpec, HttpHeaderSpec, FramingSpec, Http2FramingSpec, HttpMessageRenderingSpec and the two Http*DetailedStringExampleSpec doc specs — 201 tests, 0 failures
  • No directional test added: pure type-alias refactor with no behavioural change; the existing suites are the directional coverage

References

None - follows apache/pekko#3539

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 pjfanning added this to the 2.0.0-M2 milestone Sep 12, 2026
@pjfanning
pjfanning merged commit f019432 into apache:main Sep 12, 2026
6 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.

3 participants