refactor: replace deprecated collection aliases in internal io code - #3467
Merged
Merged
Conversation
`GenTraversableOnce` and `immutable.Traversable` are deprecated aliases
for `IterableOnce` and `immutable.Iterable` respectively, kept for the
2.12 migration. Three internal sites still use them, each carrying a
`@nowarn("msg=deprecated")` to suppress the resulting warning:
- Message.parse's `flattener` implicit conversion in DnsMessage
- TcpConnection.completeConnect
- the TcpIncomingConnection constructor
Use the current names and drop the suppressions, which are now stale.
That is the substantive part: an `@nowarn("msg=deprecated")` on a class
or method silences every deprecation warning in its scope, so leaving
them would keep hiding warnings unrelated to the aliases.
All three sites are internal -- `Message` is `private[internal]`, and
`TcpConnection` and `TcpIncomingConnection` are `private[io]` -- so no
public signature changes. The aliases are identical types, so this is
behaviour preserving.
The public API still uses `immutable.Traversable` in Tcp, Udp,
UdpConnected and stream's Tcp. Those are deliberately left alone: the
Scala signature would change, and `Udp.SimpleSender` is a case class, so
`copy` and `unapply` would change with it. They belong in a considered
API change, not here.
pjfanning
requested review from
He-Pin,
Philippus,
nvollmar,
raboof and
samueleresca
August 25, 2026 11:32
nvollmar
approved these changes
Aug 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
scala.collection.GenTraversableOnceandscala.collection.immutable.Traversableare deprecated aliases retained for the 2.12 migration — they resolve toIterableOnceandimmutable.Iterable. Three internal sites still use them, and each carries a@nowarn("msg=deprecated")to silence the resulting warning:DnsMessage.scala:170—Message.parse'sflattenerimplicitGenTraversableOnceTcpConnection.scala:226—completeConnectimmutable.TraversableTcpIncomingConnection.scala:33— constructorimmutable.TraversableModification
Use the current names and drop the three
@nowarnsuppressions.The suppressions are the substantive part of this change.
@nowarn("msg=deprecated")on a class or method silences every deprecation warning in its scope, not just the one it was added for. I verified all three were stale by removing them and recompiling — the code builds clean without them. Left in place they would keep hiding unrelated deprecation warnings in those files indefinitely; inTcpIncomingConnectionthe annotation sits on the whole class.Scope and safety
All three sites are internal:
Messageisprivate[internal]TcpConnectionandTcpIncomingConnectionareprivate[io], and the only two callers ofcompleteConnect(TcpIncomingConnection.scala:46,TcpOutgoingConnection.scala:112) are in the same packageThe aliases are identical types, so this is behaviour preserving — no erasure change, no signature change visible outside
io.What is deliberately not in this PR
The public API still uses
immutable.Traversable, inTcp.scala:138,167,Udp.scala:118,139,UdpConnected.scala:112andstream/scaladsl/Tcp.scala:144,186,220. Those are left alone on purpose: the Scala pickle signature changes even though erasure does not, andUdp.SimpleSenderis a case class socopyandunapplywould change with it. That is a considered API change for a major release, gated on+mimaReportBinaryIssues, not a drive-by refactor. Their@nowarns stay for the same reason.Tests
No new tests. This is a type-alias substitution with no behaviour change, and the affected paths already have coverage —
MessageSpecexercisesMessage.parseand therefore theflattenerimplicit directly.actor-tests/testOnly org.apache.pekko.io.dns.*— 60 tests passactor-tests/testOnly org.apache.pekko.io.dns.internal.* org.apache.pekko.io.TcpConnectionSpec org.apache.pekko.io.TcpIntegrationSpec— 94 passsbt actor/mimaReportBinaryIssues— cleansbt ++3.3.8 actor/compile— passes. Worth calling out:GenTraversableOnceandIterableOncediffer in availability between Scala 2.13 and 3, andDnsMessage.scalais a single shared source file rather than a cross-version variant, so Scala 3 was the real risk in this change.scalafmtrunReferences
Last of the items from the Java 8 / Scala 2.12 legacy sweep, following #3465 and #3466.