Skip to content

feat(sorted_map): make trait promotions explicit via extend#3858

Merged
bobzhang merged 1 commit into
mainfrom
hongbo/extend-sorted_map
Jul 22, 2026
Merged

feat(sorted_map): make trait promotions explicit via extend#3858
bobzhang merged 1 commit into
mainfrom
hongbo/extend-sorted_map

Conversation

@bobzhang

Copy link
Copy Markdown
Contributor

Summary

Part of the per-package series migrating moonbitlang/core off implicit trait-method promotion (see #3849 for deque). This one covers sorted_map only.

Promote — plain pub extend Deprecate — #deprecated(…, skip_current_package=true) + #doc(hidden)
Default @quickcheck.Arbitrary, @debug.Debug, Eq, @json.FromJson, the whole Show trait, ToJson
  • Show is deprecated for collectionsSortedMap's Show impl is already #deprecated on main (→ @debug.Debug).
  • ToJson/FromJson point to the @json.to_json / @json.from_json free functions; each deprecation message names the concrete replacement.
  • #doc(hidden) on all deprecations, so pkg.generated.mbti gains only SortedMap::default.

Migrates sorted_map's own blackbox test off the now-deprecated .to_json() (→ @json.to_json(...)). Scoped to sorted_map/.

Verification

  • moon check --deny-warn --target all — clean.
  • moon test -p moonbitlang/core/sorted_map --target all — green (87×4).

Signed-off-by: Codex CLI <codex@openai.com>

Copilot AI review requested due to automatic review settings July 22, 2026 07:37
@coveralls

coveralls commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 5306

Coverage remained the same at 91.293%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 17400
Covered Lines: 15885
Line Coverage: 91.29%
Coverage Strength: 196792.46 hits per line

💛 - Coveralls

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the sorted_map package away from implicit trait-method promotion by making promotions explicit via an extends.mbt shim, aligning with the ongoing per-package migration series (as previously done for deque).

Changes:

  • Enable +implicit_impl_as_method warnings for sorted_map to surface and prevent implicit promotion usage.
  • Add an extends.mbt shim that explicitly promotes Default::{default} while deprecating (and hiding from generated interface) prior promoted trait methods like ToJson::to_json, @json.FromJson::from_json, Eq, Show, etc.
  • Update sorted_map tests to use @json.to_json(...) / @json.from_json(...) instead of the deprecated promoted .to_json() method.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
sorted_map/pkg.generated.mbti Reflects the newly promoted SortedMap::default() in the generated public interface.
sorted_map/moon.pkg Enables +implicit_impl_as_method warnings for this package to enforce the migration.
sorted_map/map_test.mbt Updates JSON roundtrip tests to use @json.to_json / @json.from_json instead of deprecated promoted methods.
sorted_map/extends.mbt Introduces explicit trait promotions and hidden deprecations to replace implicit trait-method promotion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bobzhang
bobzhang enabled auto-merge (rebase) July 22, 2026 08:19
Enable `implicit_impl_as_method` (E0079) for the `sorted_map` package (in its
moon.pkg) and make its trait-impl promotions explicit via `extend`, in a
dedicated sorted_map/extends.mbt shim.

- Promote (plain `pub extend`): Default.
- Deprecate (`#deprecated(..., skip_current_package=true)` + `#doc(hidden)`):
  @quickcheck.Arbitrary, @debug.Debug, Eq, @json.FromJson, the whole Show trait
  (to_string + output), and ToJson. Each message names the concrete replacement.

SortedMap is a collection, so its Show is deprecated in favour of @debug.Debug.
ToJson is deprecated in favour of the free @json.to_json (#3850). Also migrates
sorted_map's own blackbox test off the now-deprecated `.to_json()`
(-> `@json.to_json(...)`). pkg.generated.mbti gains only SortedMap::default.

Part of the per-package series (see #3849 for deque). Scoped to sorted_map/.

Verified: `moon check --deny-warn --target all` clean; `moon test --target all` green.

Reviewed by Codex CLI: seven extends cover exactly the flagged methods, split +
replacement messages match policy, all three blackbox .to_json() callers migrated,
scoped to sorted_map/ with .mbti adding only SortedMap::default.

Signed-off-by: Codex CLI <codex@openai.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bobzhang
bobzhang force-pushed the hongbo/extend-sorted_map branch from 340aa04 to d23314f Compare July 22, 2026 08:38
@bobzhang
bobzhang merged commit 95f96cc into main Jul 22, 2026
15 checks passed
@bobzhang
bobzhang deleted the hongbo/extend-sorted_map branch July 22, 2026 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants