Conversation
…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
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
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
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
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
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
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
He-Pin
left a comment
There was a problem hiding this comment.
Triaged all 237 files: the sweep is ~95% immutable.Seq -> Seq (identical type and erasure on 2.13 and 3), with one functional change (the ByteStringBuilder fast path, inline below), one justified MiMa filter (Shape.hasOnePort internal generic signature), and no weakened tests (MetricSpec assertions are actually strengthened). CI is green on both Scala versions. One suggestion inline.
| case bs: ByteString => addAll(bs) | ||
| case xs: mutable.ArraySeq.ofByte => | ||
| if (xs.nonEmpty) putByteArrayUnsafe(xs.array.clone) | ||
| case xs: ArraySeq.ofByte => |
There was a problem hiding this comment.
This new immutable.ArraySeq.ofByte fast path is the PR's only behavior-path change and is currently covered only indirectly by the ++= property test. Consider an explicit case (e.g. in ByteStringBuilderScala213PlusSpec): addAll(array.toSeq), then mutate the source array and assert the built ByteString is unchanged, to lock in the clone/no-aliasing contract.
There was a problem hiding this comment.
Added explicit tests in ByteStringBuilderScala213PlusSpec in 7a7ce63 (branch rebased on main): both immutable.ArraySeq.ofByte (via unsafeWrapArray, which shares the array) and mutable.ArraySeq.ofByte are added, the source array is mutated before result(), and the built ByteString is asserted unchanged. Dropping the clone makes the test fail. Empty-array cases are covered too.
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
…-> 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$`).
Add explicit cases for immutable.ArraySeq.ofByte and mutable.ArraySeq.ofByte that mutate the wrapped array after addAll and assert the built ByteString is unchanged, locking in the clone/no-aliasing contract. Also cover the empty-array case for both.
7b40a40 to
7a7ce63
Compare
Motivation
The codebase still carried a number of Scala 2.12-era idioms that are redundant or deprecated on Scala 2.13/3:
immutable.Seqqualifiers (scala.Seqhas beenimmutable.Seqsince 2.13), the deprecatedmutable.WrappedArrayalias,filterKeys/mapValuesonMap,Eitherleft/right projections, and.toIterator/Streamin user-facing doc snippets.Modification
immutable.SeqwithSeqacross ~210 files and drop the now-unusedscala.collection.immutableimports.scala.Seqis a type alias forscala.collection.immutable.Seqon 2.13 and 3, so this is source- and binary-compatible (same erasure).DslFactoriesConsistencySpecis left as-is since it deliberately distinguishescollection.Seqfromimmutable.Seq.ByteStringBuilder.addAll: matchmutable.ArraySeq.ofByteandimmutable.ArraySeq.ofByteinstead of the deprecatedWrappedArray.ofByte.Array.toSeq/toIndexedSeqproduceimmutable.ArraySeq.ofByteon 2.13, which previously fell through to the generic path.ByteStringBuilderScala213PlusSpec: explicit cases for bothArraySeq.ofBytefast paths that mutate the wrapped array afteraddAlland assert the builtByteStringis unchanged (plus the empty-array case).CanBuildFromblock inByteString.ManifestInfo: replace deprecatedfilterKeys(and its@nowarn) withfilter.ShardRegionscaladoc example:filterKeys->filter.Source(Stream.from(1))->Source(LazyList.from(1))(KillSwitchDocSpec),buffer.toIterator->buffer.iterator(GraphStageDocSpec).Shrink.withLazyListinstead ofShrink(_ => Stream.empty),view.mapValuesinstead of a@nowarnwrapper,.iteratorinstead of.toIterator, and plainEitherequality instead of.left.get/.right.get(dropping the@nowarnonMetricNumericConverterSpec).@apidocscala anchors updated fromimmutable.SeqtoSeqto match the regenerated scaladoc ids (all 25Seq-bearing anchors verified againststream/docoutput); four anchors that were already broken onmainwere corrected while touching them.IncompatibleSignatureProblemfilter forShape.hasOnePort(@InternalApi private[pekko]): erased descriptor is unchanged, only the Java generic signature moved fromSeq<?>toSeq<Object>.The 2.12 branches in
project/PekkoDisciplinePlugin.scalaand thefilterKeys/mapValuesuses underproject/(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
scalafmtrun on all changed filessbt "actor-tests/testOnly org.apache.pekko.util.ByteStringBuilderScala213PlusSpec"— 5 passed; removing thecloneon theimmutable.ArraySeq.ofBytepath makes the new test failsbt stream/mimaReportBinaryIssuespasses locally with the filtersbt stream/docgenerated and used to verify the paradox anchorsTest/compileand tests: relying on CIReferences
None - Scala 2.12 support was dropped previously