extend type
Platform spec node
extend type
Spec standingStandard
No architecture decision records under adr/ for this feature yet. Standard features must
publish at least one ADR or keep a ## Decisions summary on the hub.
- Code style and naming Language-level naming and style conventions that affect readability and tooling consistency.
- extend type Type extension syntax replacing impl blocks; public members only, full type scope access.
- Modules and visibility File layout, `public`/`internal` boundaries, and how packages compose. The driver and package manager use the same module graph the typechecker sees.
- Name resolution Scopes, imports, and shadowing tie syntax to symbols. Diagnostics for unresolved names must cite these rules verbatim.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
scope | yes | yes |
features | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Purpose
extend type is the normative mechanism for adding members to an existing type. It replaces prior impl-block extension patterns for user and generated code.
Syntax
extend type Account{ pub unit Deposit(f32 amount) { account.balance += amount; }}The extended type name (Account) must refer to an in-scope type declaration. The body may declare methods and other members allowed by the type system for that target.
Access rules
- Members inside
extend typemay access public members of the extended type only. - Private member access is forbidden inside
extend typebodies. extend typedoes not bypass module visibility; extension sites must satisfy normal import and visibility rules.
Compiler mods
Generator contracts may emit extend type blocks as typed AST contributions. Generated extensions follow the same access and visibility rules as hand-authored extensions.