You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: AGENTS.md
+77Lines changed: 77 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,3 +32,80 @@ Each package has its files and blackbox test files (common, ending in `_test.mbt
32
32
like `assert_eq` when you are in some loops where each snapshot may vary. You can use `moon coverage analyze > uncovered.log` to see which parts of your code are not covered by tests.
33
33
34
34
- agent-todo.md has some small tasks that are easy for AI to pick up, agent is welcome to finish the tasks and check the box when you are done
35
+
36
+
# Trait-method promotion (`extend`)
37
+
38
+
When a type `impl`s a trait, the trait's methods can be *promoted* to inherent
39
+
methods (`x.method(..)`) via an explicit `pub extend` block in the package's
40
+
`extends.mbt`. The rule for what we promote vs. deprecate
41
+
(`#deprecated(.., skip_current_package=true)` + `#doc(hidden)`) is driven by
42
+
**where the trait lives** — because promoting a method couples the type's
43
+
package to the trait's package:
44
+
45
+
-**Traits whose home is `builtin`** (`Add`…`Sub`, `Compare`, `Eq`, `Hash`,
46
+
`Show`, `Default`, `Logger`, `ToStringView`): every package already depends on
47
+
`builtin`, so promoting them creates **no cycle** — safe on any type.
48
+
-**Traits whose home is a higher package** (`@json.FromJson`,
49
+
`@quickcheck.Arbitrary`, `@debug.Debug`): promoting them on a lower-level type
50
+
would form a cycle (`builtin → json` etc.), so they are **never promoted** —
51
+
always use the free function (`@json.from_json`, `@quickcheck.…`,
52
+
`@debug.Debug`).
53
+
54
+
This is about the trait's *logical* home, not the file it currently sits in:
55
+
**`ToJson` lives in `builtin` today only for bootstrapping but belongs in
56
+
`@json`**, so it is treated as a higher-package trait (not promoted) — promoting
0 commit comments