Skip to content

[Scala 3] consolidate type+val aliases to export#872

Open
halotukozak wants to merge 5 commits into
AVSystem:scala-3from
halotukozak:03-06-aliases-to-export
Open

[Scala 3] consolidate type+val aliases to export#872
halotukozak wants to merge 5 commits into
AVSystem:scala-3from
halotukozak:03-06-aliases-to-export

Conversation

@halotukozak

Copy link
Copy Markdown
Contributor

Slice: 3.6 of Phase 3 (Scala 3 syntax modernization)
Merge order: Independent — can land any time (no overlap with 3.1/3.2/3.3/3.4/3.5)
Depends on: none
Base branch: upstream/scala-3 (not stacked)

Consolidate type X = Y; final def X: Y.type = Y and type X = Y; final val X: Y.type = Y patterns into Scala 3 export Y (or export Y as X for rename) clauses. Reduces redundancy: a single declaration re-exports both the type AND the term.

Touches:

  • core/.../CommonAliases.scalaTry/Success/Failure/Future/Promise/ExecutionContext/NonFatal/ClassTag/classTag/Annotation/StaticAnnotation
  • core/.../misc/MiscAliases.scalaOpt/OptArg/NOpt/OptRef
  • core/.../collection/CollectionAliases.scala — ~30 rename pairs (BIterable/IIterable/MIterable/…/MArrayBuffer); MColBuilder retained as plain type (RHS is HK substitution, not a pure rename)

MIGRATION.md §3 updated with the source-compat note.

sbt compile + Test/compile + scalafmtCheckAll exit 0. No new warnings, no @nowarn/-Wconf.

Drift note

halotukozak fork (origin/master) already uses export for CommonAliases and MiscAliases; we mirror it. For CollectionAliases the fork still keeps the type + final def pair shape — we diverge per user directive 2026-06-01 to consolidate via export.

Replace `type X = Y` + `final val X = Y` pairs with single Scala 3
`export` clauses. Behavior identical for downstream (same imports
resolve, same types/terms available); declaration count cut in half.

Mirrors halotukozak fork `origin/master` shape for CommonAliases.
Replace `type X[+A] = ... ; final val X = ...` pairs with single
`export` clauses. Mirrors halotukozak fork shape.
Replace `type X[+A] = pkg.Y[A]` + `final def X: pkg.Y.type = pkg.Y`
pairs with single Scala 3 `export pkg.Y as X` clauses. Each rename
collapses two declarations to one; variance is preserved by the
re-exported source symbol.

`MColBuilder` kept as plain `type` — its RHS shape
(`scm.Builder[Elem, Col[Elem]]`) is a higher-kinded substitution,
not a symbol rename, so `export` doesn't apply.

`MBuilder` converts cleanly (pure rename of `scm.Builder`).

Drift from halotukozak fork: fork `origin/master` keeps the
`type + final def` pair shape for CollectionAliases. We diverge
per user directive 2026-06-01 to consolidate via `export`.

Also modernized one Scala 2-style import to Scala 3 form
(`scala.{collection => sc}` → `scala.collection as sc`).
Trivial polish: now that `MBuilder` is exported, `MColBuilder`'s
RHS references the project-local alias instead of `scm.Builder`
directly. Pure cosmetic; same resolved symbol.
Document the `CommonAliases` / `MiscAliases` / `CollectionAliases`
shape change in MIGRATION.md §3 source-compat. Source-level callers
unaffected; JVM bytecode no longer emits redundant forwarders.
@halotukozak halotukozak added this to the Scala 3 milestone Jun 1, 2026
@halotukozak halotukozak marked this pull request as ready for review June 1, 2026 21:40
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