SystemNavigation
SystemNavigation — Class-registry navigation queries ("who implements X", "where is X used").
Home for System Browser-style navigation queries that previously lived
on Beamtalk (BT-2189 / BT-2190). A stateless, single-scope service, so
it is a class-side facade (ADR 0129): every query is a class sealed
method and there is no instance to construct. Sealed class-side sends run
in the caller (direct dispatch), for both static and dynamic receivers, so
the walk over every class is never re-entrant.
Examples
SystemNavigation implementorsOf: #asString
SystemNavigation sendersOf: #+
Methods
- class » allClasses
- class » classesNamed: names
- class » liveClassesIn: aScope inject: initial into: aBlock
- class » liveClassesIn: aScope select: aBlock
- class » isRemoved: aClass
- class » sortedByName: classes
- class » sortKeyOf: aClass
- class » actorClasses
- class » dnuHandlers
- class » usersOf: aProtocolName
- class » requireClassName: aClass selector: aSelector
- class » classesInPackage: aPackageName
- class » subclassesOf: aClass in: aPackageName
- class » requirePackage: aPackageName
- class » implementorsOf: aSelector
- class » indexedImplementorsFrom: indexedRows
- class » messagesSentBy: aMethod
- class » sendersOf: aSelector
- class » senderClassFor: ownerTag classSide: isClassSide
- class » indexedSiteRecordsFrom: indexedRows into: result
- class » indexedSelectorsFrom: indexedRows into: result
- class » walkMethodsOf: aScope into: result do: aBlock
- class » collectSendersFor: aSelector in: aScope into: result
- class » appendSendersIn: methodSource selector: aSelector class: aClass methodSelector: methodSel into: result
- class » announcementsSentBy: aClass
- class » announcementSitesSentBy: aClass
- class » collectAnnounceSitesIn: aScope into: result
- class » appendAnnounceSitesIn: methodSource class: aClass methodSelector: methodSel into: result
- class » isAnnouncementClass: aClass
- class » referencesTo: aClass
- class » collectReferencesFor: targetName in: aScope into: result
- class » appendReferencesIn: methodSource targetName: targetName owner: ownerClass methodSelector: methodSel into: result
- class » fieldReadersOf: aSym in: aClass
- class » fieldWritersOf: aSym in: aClass
- class » collectFieldAccessesOf: aSym in: aClass readers: wantReaders
- class » collectFieldAccessesFor: aSym in: aScope readers: wantReaders into: result
- class » appendFieldAccessesIn: methodSource field: aSym owner: ownerClass methodSelector: methodSel readers: wantReaders into: result
- class » ffiSitesFor: aSpec
- class » parseFfiSpec: aSpec
- class » raiseFfiSpecError: aSpec
- class » collectFfiSitesFor: module function: function arity: arity in: aScope into: result
- class » appendFfiSitesIn: methodSource module: module function: function arity: arity owner: ownerClass methodSelector: methodSel into: result
- class » methodsMatching: aRegex
- class » collectMethodsMatching: aRegex in: aScope into: result
- class » selectorsMatching: aPattern
- class » selectorsForClass: aClass
- class » unimplementedSelectors
- class » unionFallbackClasses: a with: b
- class » definedSetFromIndex: definedRows into: result
- class » dnuHandlerScopesFrom: definedRows fallback: fallbackScope into: result
- class » dnuScopeKeyForOwner: ownerTag classSide: isClassSide
- class » dnuScopeKeyFor: aScope
- class » groupIndexedSends: sendRows excluding: excluded dnuScopes: dnuScopes into: result
- class » runtimeProvidedSelectors
- class » collectAllSendsIn: aScope excluding: excluded into: result
- class » appendAllSendsIn: methodSource owner: ownerClass methodSelector: methodSel handlesDnu: handlesDnu excluding: excluded into: result
- class » recordSend: sentSel line: line recv: recv owner: ownerClass methodSelector: methodSel handlesDnu: handlesDnu excluding: excluded into: result
- class » unusedSelectors
- class » sentSetFromIndex: indexedSent into: result
- class » runtimeCalledSelectors
- class » collectSentSelectorsIn: aScope into: result
- class » addSentSelectorsIn: methodSource into: result
- class » collectUnusedFor: aScope owner: owner sent: sent excluded: excluded into: result
- class » recordUnused: methodSel scope: aScope owner: owner isTestCase: isTestCase sent: sent excluded: excluded into: result
- class » isTestRunnerSelector: aSelector
- class » isPrimitiveMethod: methodSel in: aScope
- class » xrefImplementorsOf: aSelector
- class » xrefSendersOf: aSelector
- class » xrefReferencesTo: aSymbol
- class » xrefDefinedSelectors
- class » xrefAllSends
- class » xrefAllSentSelectors
- class » findClass: aName
- class » registeredClassesNamed: names
- class » liveClassNameOf: aClass
- class » allSendsIn: aSource
- class » sendersIn: aSource selector: aSelector
- class » referencesIn: aSource class: aName
- class » announceSitesIn: aSource
- class » fieldReadersIn: aSource field: aSym
- class » fieldWritersIn: aSource field: aSym
- class » ffiSitesIn: aSource module: aModule function: aFunction arity: anArity
- class » classObjectTag: aName
Class Methods
Snapshot of the class registry visible to this navigation query.
Currently always returns the full registry. Future scoped instances
(BT-2201) will override this to filter by package or explicit class
list. Wrapping the FFI in a typed instance method lets downstream
block parameters infer Class / Behaviour instead of Dynamic.
Resolve class names to the classes still registered, dropping any name that is no longer registered.
Turns an xref miss partition's #fallback_classes into a walk scope from
the registry snapshot (no message to any class process), in place of
filtering allClasses by cls name, which sent name to every class.
Examples
SystemNavigation classesNamed: #(#Integer, #NoSuchClass) // => [Integer]
Fold aBlock over the classes of aScope, skipping any class that has
been removed from the system.
A class already removed when the walk reaches it is skipped without being
sent anything. If aBlock raises for a class, the class is checked again:
if it was removed while aBlock ran, the error is dropped and the walk
continues with the next class; otherwise the error is re-raised, so
genuine failures are not hidden. Extend the accumulator only after your
sends, so a skipped class leaves nothing partial behind. The removal
check reads the registry's metadata, never the class process.
Examples
SystemNavigation liveClassesIn: #(Integer) inject: 0 into: [:n :c | n + 1] // => 1
The classes of aScope for which aBlock answers true, skipping any
class removed mid-walk. A select: over liveClassesIn:inject:into:.
Examples
SystemNavigation liveClassesIn: #(Integer) select: [:c | true] // => [Integer]
Whether aClass (a class or metaclass) has been removed from the system.
Reads the registry's metadata; sends nothing to the class.
Examples
SystemNavigation isRemoved: Integer // => false
Sort classes by class name, dropping any class removed since it was
collected. Names come from the registry's metadata, so a class removed
between the walk and the sort cannot make the comparator raise (one
removed during the sort itself keeps its place under the key "").
The sort key sortedByName: uses: the registered class name as a String,
or "" for a class removed since the caller's check.
Return every class that participates in the actor model — i.e. each class
whose superclassChain includes Actor.
Includes Actor itself (the abstract root); callers wanting only concrete
actors can filter it out. Iterates allClasses, so stdlib and
user-defined actor classes are both in scope. Returns [] if Actor is
not in the loaded image (defensive).
Sorted alphabetically by class name for a stable, snapshot-friendly order.
name is read directly on the Behaviour-typed elements (it lives on
Behaviour per BT-2232), so no dnu suppression is needed.
Examples
SystemNavigation actorClasses // => [Actor, ClassBuilder, ...]
Return every class that overrides the does-not-understand handler — i.e.
each class that locally defines doesNotUnderstand:args: (Beamtalk's DNU
override selector — note the :args:, NOT the Smalltalk-classic
doesNotUnderstand:).
These are the escape-valve classes — proxies, builders, DSL frontends —
whose instances can absorb arbitrary message sends. Useful for seeing
which classes might respond to a selector that has no static implementor,
and as an input to the unimplementedSelectors lint, which excludes sends
to DNU-routed receivers.
Includes ProtoObject, the root definer of the handler (matching the
methods includes: #doesNotUnderstand:args: convention used elsewhere in
this class); callers wanting only genuine overrides can filter it out.
Iterates allClasses, so stdlib and user-defined classes are both in
scope. includesSelector: checks the local method dictionary, so
inherited (un-overridden) handlers are not reported. Sorted alphabetically
by class name for a stable, snapshot-friendly order.
Examples
SystemNavigation dnuHandlers // => [ErlangModule, ProtoObject, ...]
Return the classes that compose (uses:) a protocol.
Shares Protocol usersOf:'s implementation rather than re-querying the
registry — the two are the same query reached from two entry points
(a protocol-centric one and a System Navigation one), matching this
class's other Protocol-registry-backed queries (implementorsOf: for
selectors, this for protocol composition). Order is unspecified.
Examples
SystemNavigation usersOf: #Comparable // => [DateTime, Money, ...]
Validate that aClass is a class/metaclass object and return its name
Symbol, raising a typed error otherwise. aSelector names the calling
query for the message. Mirrors the argument guard in referencesTo:;
respondsTo: #subclasses is the reliable "is a class" test (see that
method for why isKindOf: Behaviour is not).
Return the class objects belonging to package aPackageName (ADR 0070).
Delegates to Package classes: (which returns class-name Symbols) and
resolves each to a class object via findClass:. The package argument may
be a Symbol or String. Raises a typed error if the package is not loaded
(so a typo surfaces rather than silently returning []); returns [] if
the package exists but is empty.
Examples
SystemNavigation classesInPackage: #stdlib // => [Actor, Array, ...]
Return the subclasses of aClass that live in package aPackageName
(ADR 0070) — allSubclasses filtered by package.
The package argument may be a Symbol or String. Raises a typed error if
the package is not loaded; returns [] if no subclasses live in that
package. A class's package is read via Package packageNameFor: (the same
authority behind metaclass packageName).
Examples
SystemNavigation subclassesOf: Number in: #stdlib // => [Float, Integer]
Normalise aPackageName (Symbol or String) to a package-name String,
raising the dedicated #package_not_found error (via Package named:) if
it is not a currently-loaded package. Lets the package queries distinguish
"package doesn't exist" (a typo) from "package has no matching classes" (a
legitimately empty result), and reuses the same error type callers already
get from Package named:.
Return all classes that locally define the given selector.
Searches both instance-side and class-side definitions:
instance-side hits appear as class objects (e.g. Integer),
class-side hits appear as metaclass objects (e.g. Counter class).
A class that defines the selector on both sides appears twice — once
as the class and once as the metaclass.
Does NOT walk inherited methods — only classes with their own definition of the selector are returned.
Matches Pharo's SystemNavigation >> #allImplementorsOf:.
Maintained index (ADR 0087, BT-2302)
The implementors are read from the runtime-maintained xref methods table
(beamtalk_xref), populated at class-load time by codegen's baked
register_class/0 payload — one methods row per {class, side, selector} definition. This is a sub-millisecond ETS read in place of the
former includesSelector: probe over every class in the scope.
Miss policy. Mirrors sendersOf::
- Indexed implementor rows whose class is no longer loaded are dropped silently (stale), including a class removed after the partition was read (BT-4111): such a row is dropped, never reported as a raw Symbol.
- A class the registry reports as loaded but that is absent from the index
falls back to the legacy
includesSelector:/class includesSelector:probe for that class only, and the runtime logs onexref_misswarning. The partition is computed runtime-side bybeamtalk_xref:implementors_of_bt/1.
Raises an error if the argument is not a Symbol.
Examples
SystemNavigation implementorsOf: #asString // => [Integer, Float, String, ...]
SystemNavigation implementorsOf: #new // => [..., Counter class, ...]
SystemNavigation implementorsOf: #nonExistent // => []
Map indexed implementor rows (#{#owner, #class_side}) to the class
object (instance side) or metaclass object (class side). Uses the same
owner-tag/class-side resolver as sendersOf:.
BT-4111: a row whose owner no longer resolves (the class was removed after the xref partition was read) is dropped, so the result only ever holds classes, never a raw owner Symbol.
Return the message sends that occur in the body of aMethod — the
outgoing-call set of a single method, the dual of sendersOf:.
Each result is a Dictionary with two keys:
#selector— the selector being sent (a Symbol)#line— the 1-based line number withinaMethod sourcewhere the send appears
Order matches the AST walk: outer sends come before sends in their receiver/argument subtrees (a stable pre-order). A method that sends the same selector multiple times produces one entry per occurrence.
Backs the callHierarchy/outgoingCalls LSP query (BT-2243). The runtime
path used by Backend::delegate_nav_query reads the method source via
aMethod source and asks the compiler for every send — the same
per-method AST walk that powers unimplementedSelectors (BT-2206),
inverted to one-method-many-sends instead of all-methods-one-selector.
Erlang FFI receivers (Erlang foo / (Erlang foo) bar:) are excluded:
those are Erlang function calls routed through the ErlangModule DNU
bridge, not Beamtalk message sends, so reporting them as outgoing calls
would let an Erlang function name shadow a Beamtalk selector in the
caller's call hierarchy. Mirrors the same exclusion in unusedSelectors.
aMethod must be a CompiledMethod (the value returned by
aClass >> #selector). Passing anything else raises a typed error.
A method whose source is nil (a primitive / intrinsic registered
without source text) returns [].
Examples
method := Counter >> #increment
SystemNavigation messagesSentBy: method
// => [#{#selector => #+, #line => 2}, ...]
Return a collection of call sites that send the given selector.
Each result is a Dictionary with three keys:
#class— the class whose method contains the send (the class object for an instance-side hit, the metaclass object for a class-side hit)#selector— the selector of the method that contains the send#line— the 1-based line number within the method source where the send appears
A method that sends aSelector multiple times produces one record per
occurrence. Matches Pharo's SystemNavigation >> #allSendersOf:.
Maintained index (ADR 0087, BT-2299)
The class-body call sites are read from the runtime-maintained xref index
(beamtalk_xref), populated at class-load time by codegen's baked
register_class/0 payload. This is a sub-millisecond ETS read in place of
the former per-call walk over every method source — see
docs/development/benchmarks.md.
Miss policy. The index is authoritative for loaded classes, but a miss must never become a wrong answer:
- Rows whose owning class is no longer loaded are dropped silently (stale), including a class removed after the partition was read (BT-4111).
- A class the registry reports as loaded but that is absent from the index
falls back to the legacy source-scan (
collectSendersFor:in:into:) for that class only, and the runtime logs onexref_misswarning. The partition is computed runtime-side bybeamtalk_xref:senders_of_bt/1.
Raises an error if the argument is not a Symbol. Returns an empty collection if no senders are found (not an error).
Examples
SystemNavigation sendersOf: #asString // => [#{#class => Counter, #selector => ..., #line => 7}, ...]
SystemNavigation sendersOf: #neverCalledXyzzy // => []
Resolve an xref sender row's owning class (a class-name Symbol) and side
flag to the class object the result record exposes as #class.
Instance-side hits report the class object; class-side hits report the
metaclass object (<class> class), matching the legacy scan's cls /
cls class convention (BT-2195).
Answers nil when the owner no longer resolves — a class removed after
the xref rows were read. Every caller drops such a row (BT-4111), so a
query never reports a raw owner Symbol in place of a class.
BT-4095: the class-side hit resolves the metaclass tag (#'Foo class')
through the registry, rather than sending isKindOf: and class to the
class, so a class removed mid-query cannot make the mapping raise.
Map the xref index bt_row()s returned by beamtalk_xref:senders_of_bt/1
or references_to_bt/1 onto #{#class, #selector, #line} result records,
appending to result.
Each row is a Dictionary with atom keys #owner (class-name Symbol),
#class_side (Boolean), #method (Symbol), and #line (positive
Integer). #class is resolved via senderClassFor:classSide: so the
record shape is byte-for-byte identical to the legacy source-scan path.
A row whose owner no longer resolves (class removed since the rows were
read) is dropped (BT-4111).
The bt_row() shape is shared by senders and references (both index a
site to the containing method's selector), so the same mapper backs both
sendersOf: and referencesTo: (BT-2302). The explicit
-> List(Dictionary) return anchors element-type inference for the
accumulator.
Map the indexed defined_selectors_bt rows to their #selector Symbols,
appending to result. Each row's at: #selector access is Dynamic, so
the explicit -> List(Symbol) return anchors element-type inference for
the selectorsMatching: fallback accumulator (mirrors
indexedSiteRecordsFrom:into:), keeping acc strongly typed rather than
Dynamic (BT-2302).
The one per-class method walk shared by every collect*For:in:into: scan.
Folds aBlock ([:acc :method :methodSel | ...], answering the next
accumulator) over each method of aScope (a class or metaclass), starting
from result, and returns the final accumulator.
Fetches each method via >>, guarded with respondsTo: so a scope for
which >> is not yet supported (e.g. metaclass-shaped registry entries)
is silently skipped rather than aborting the whole walk. A selector with
no method object contributes nothing; aBlock only sees real methods and
decides itself what a nil source means.
Append senders of aSelector found in any instance method of aScope
(a class) to result. Returns the (possibly extended) result list.
Internal helper for sendersOf:. Iterates aScope methods, fetches
each method's source via >>, and asks the compiler to find matching
MessageSend line numbers.
Guards the >> send with respondsTo: so a class for which >>
is not yet supported (e.g. metaclass-shaped registry entries) is
silently skipped rather than aborting the whole walk.
Append one record per matching MessageSend found in methodSource.
Internal helper for collectSendersFor:in:into:. Splits the per-method
FFI call out so the surrounding inject:into: body stays a single
expression, which keeps the type-inference behaviour predictable.
Return the distinct Announcement subclasses that aClass statically
emits — the publisher-side dual of AnnouncementNavigation (ADR 0093 §7,
BT-2475).
Where AnnouncementNavigation answers "who listens for which events"
from the live runtime ETS subscription table, this answers "which event
classes does aClass publish" by mining the announce: /
announceAndWait: / announceAndWait:timeout: call sites out of
aClass's own method bodies (instance side + class side). The result is the distinct set of resolved
announcement classes, sorted by name for a stable snapshot; [] when
aClass emits nothing statically resolvable.
Advisory, not a complete contract
This is a static analysis of a dynamic language: it reports an emission
only when the event argument resolves to a concrete Announcement
subclass at the call site — a constructor call on a bare class reference
(announce: (PriceChanged newPrice: 42) or announce: PriceChanged new).
A Dynamic-typed or indirect argument (announce: someVar,
perform:-style dispatch) is unresolvable by construction and is
silently skipped — it is a documented limitation, never an error. Treat
the result as advisory discoverability, not a sound or exhaustive emission
contract.
Raises a typed error if aClass is a Symbol/String rather than a class
object (argument-validation parity with referencesTo:).
Examples
SystemNavigation announcementsSentBy: PriceTracker // => [PriceChanged, ...]
SystemNavigation announcementsSentBy: SilentClass // => []
Return a collection of the announcement emission sites within aClass —
the site-level form of announcementsSentBy: for IDE / event-graph use
(BT-2475).
Each result is a Dictionary with four keys, the sendersOf: shape plus the
resolved announcement class:
#class— the publisher class whose method contains the emission (the class object for an instance-side hit, the metaclass object for a class-side hit)#selector— the selector of the method that contains the emission#line— the 1-based line number within the method source where theannounce:send appears#announcementClass— the resolvedAnnouncementsubclass being emitted
A method that emits the same announcement multiple times produces one
record per occurrence. Only sites whose event argument resolves to a
concrete Announcement subclass are reported; unresolvable
(Dynamic-typed / indirect) sites are skipped (see announcementsSentBy:
for the advisory-analysis discipline).
Scope mirrors sendersOf:'s source-scan: aClass's instance side and
class side. Unlike sendersOf:, this query is not index-backed: the
xref index records selectors and lines but not argument types, so each
method source is re-parsed via the compiler to resolve the event argument.
Raises a typed error if aClass is a Symbol/String rather than a class
object. Returns an empty collection if no resolvable emissions are found.
Examples
SystemNavigation announcementSitesSentBy: PriceTracker
// => [#{#class => PriceTracker, #selector => #notify, #line => 4,
// #announcementClass => PriceChanged}, ...]
Append announcement emission sites found in any method of aScope (a class
or metaclass) to result. Returns the (possibly extended) result list.
Internal helper for announcementSitesSentBy:. Iterates aScope methods,
fetches each method's source via >>, and asks the compiler for the
announce: sites in it (with their resolved argument classes). Mirrors
collectSendersFor:in:into:; the >> send is guarded with respondsTo:
so a scope for which >> is not yet supported (e.g. metaclass-shaped
registry entries) is silently skipped, and a nil source (a primitive
registered without source text) contributes nothing.
Append one record per resolvable announcement emission found in
methodSource.
Internal helper for collectAnnounceSitesIn:into:. Splits the per-method
FFI call out so the surrounding inject:into: body stays a single
expression — same shape as appendSendersIn:selector:class:methodSelector:into:.
The compiler hands back one {Line, ClassNameBinary} tuple per announce
site; the class-name binary is resolved to a live class via findClass:
(which answers nil for the empty-binary "unresolvable" marker). A site is
recorded only when its argument resolves to a class that is an
Announcement subclass — unresolvable arguments and non-announcement
receivers (a misclassified constructor send) are both skipped.
Whether aClass is a loaded Announcement subclass (self-inclusive of
Announcement itself) — the gate that keeps announcementsSentBy: from
reporting a non-announcement class that a heuristic constructor match
happened to resolve.
nil (an unresolvable argument) and any value that does not respond to
superclassChain (not a class object) answer false. Returns false
defensively if Announcement is not in the loaded image. Uses
superclassChain includes: exactly as actorClasses tests membership of
Actor.
BT-4111: the class is probed through the tolerant walk, so a class
removed before or during the probe answers false instead of raising.
Return a collection of references to the given class.
Each result is a Dictionary with three keys:
#class— the class whose method contains the reference (the class object for an instance-side hit, the metaclass object for a class-side hit)#selector— the selector of the method that contains the reference#line— the 1-based line number within the method source where the reference appears
A method that mentions aClass multiple times produces one record per
occurrence. Class names that appear in type annotations (parameter,
return, or generic parameters such as List(Counter)) are also matched.
Matches Pharo's SystemNavigation >> #allReferencesTo:.
Maintained index (ADR 0087, BT-2302)
The class-body reference sites are read from the runtime-maintained xref
index (beamtalk_xref), populated at class-load time by codegen's baked
register_class/0 payload (the same references channel that feeds the
methods / senders tables). This is a sub-millisecond ETS read in place of
the former per-call walk over every method source — same envelope as
sendersOf:, see docs/development/benchmarks.md.
Miss policy. Identical to sendersOf::
- Rows whose owning class is no longer loaded are dropped silently (stale).
- A class the registry reports as loaded but that is absent from the index
falls back to the legacy source-scan (
collectReferencesFor:in:into:) for that class only, and the runtime logs onexref_misswarning. The partition is computed runtime-side bybeamtalk_xref:references_to_bt/1.
Argument must be a class object (a Behaviour). Passing a Symbol or
String — the most common mistake, since sendersOf: takes a Symbol —
raises a typed error pointing the caller at the right argument shape.
Returns an empty collection if no references are found (not an error).
Examples
SystemNavigation referencesTo: Integer // => [#{#class => Counter, #selector => ..., #line => 7}, ...]
SystemNavigation referencesTo: NeverUsedClass // => []
Append references to a class (identified by targetName) found in any
instance method of aScope (a class) to result. Returns the (possibly
extended) result list.
Internal helper for referencesTo:. Iterates aScope methods, fetches
each method's source via >>, and asks the compiler to find matching
ClassReference line numbers. Mirrors collectSendersFor:in:into:.
Guards the >> send with respondsTo: so a class for which >>
is not yet supported (e.g. metaclass-shaped registry entries) is
silently skipped rather than aborting the whole walk.
Append one record per matching ClassReference found in methodSource.
Internal helper for collectReferencesFor:in:into:. Splits the
per-method FFI call out so the surrounding inject:into: body stays a
single expression — same shape as appendSendersIn:selector:class:methodSelector:into:.
Return a collection of methods that READ the named field.
Each result is a Dictionary with three keys:
#class— the class whose method reads the slot#selector— the selector of the method that reads the slot#line— the 1-based line number within the method source where the read appears
A "read" is an access self.x (where x is aSym) anywhere EXCEPT the
target of an assignment. So self.x := self.x + 1 reads x (on the RHS)
and writes it (on the LHS); the bare assignment target self.x := 0
counts as a write only, never a read (Pharo precedent). A bare local
variable x is not an field and is ignored. A method that
reads aSym multiple times produces one record per occurrence.
Scope: walks the instance-side methods of aClass and of every class in
aClass allSubclasses (a subclass inherits the slot, so methods it
defines can touch it). A class has no class-side fields (class variables
were removed, ADR 0153), so class-side methods are not walked.
aSym must be a Symbol naming the slot; passing anything else raises a
typed error. The slot must be declared on aClass — if aSym is not in
aClass allFieldNames (inherited included), a typed error is raised so a
typo surfaces rather than silently returning []. A declared-but-untouched
slot returns [].
Examples
SystemNavigation fieldReadersOf: #value in: Counter
// => [#{#class => Counter, #selector => getValue, #line => 5}, ...]
SystemNavigation fieldReadersOf: #neverReadSlot in: Counter // => []
Return a collection of methods that WRITE (assign) the named instance variable.
Each result is a Dictionary with three keys:
#class— the class whose method writes the slot#selector— the selector of the method that writes the slot#line— the 1-based line number within the method source where the write appears
A "write" is an assignment whose target is self.x (where x is
aSym). The mirror of fieldReadersOf:in:: self.x := self.x + 1
appears in BOTH result sets (write on the LHS, read on the RHS). A method
that writes aSym multiple times produces one record per occurrence.
Scope and validation are identical to fieldReadersOf:in:: walks the
instance side of aClass plus aClass allSubclasses, requires aSym to
be a declared Symbol slot, and returns [] for a declared-but-never-written
slot.
Examples
SystemNavigation fieldWritersOf: #value in: Counter
// => [#{#class => Counter, #selector => increment, #line => 3}, ...]
SystemNavigation fieldWritersOf: #neverWrittenSlot in: Counter // => []
Shared driver for fieldReadersOf:in: and fieldWritersOf:in:.
wantReaders selects which access kind to collect (reads when true,
writes when false). Validates the arguments, builds the scope (aClass
aClass allSubclasses), walks the instance side of each scope, then applies slot validation:aSymmust be a declared field ofaClass(allFieldNames, inherited included). An undeclared name raises a typed error (typo guard); a real-but-untouched slot returns[].
Append field access records found in any method of aScope
(a class or metaclass) to result. Returns the (possibly extended) list.
Internal helper for collectFieldAccessesOf:in:readers:. Iterates
aScope methods, fetches each method's source via >>, and asks the
compiler to find matching read or write line numbers. Guards the >>
send with respondsTo: so a scope for which >> is not yet supported
(e.g. metaclass-shaped registry entries) is silently skipped rather than
aborting the whole walk — mirrors collectSendersFor:in:into:.
Append one record per matching field access found in
methodSource.
Internal helper for collectFieldAccessesFor:in:readers:into:. Splits
the per-method FFI call out so the surrounding inject:into: body stays a
single expression — same shape as appendSendersIn:selector:class:methodSelector:into:.
wantReaders picks the reader vs writer FFI entry point.
Return a collection of the Erlang FFI call sites that invoke the named Erlang function across the loaded class registry.
aSpec is a String naming the target function in "module:function" form
(e.g. "lists:reverse"), optionally arity-qualified as
"module:function/arity" (e.g. "lists:reverse/1"). When an arity is
given, only call sites with exactly that argument count match; without it,
the function matches at any arity. A spec that does not match the
module:function[/arity] shape raises a typed error (kind #user_error).
An FFI call site is a send routed through the Erlang bridge —
(Erlang lists) reverse: xs or Erlang lists reverse: xs. There is no
dedicated AST node for these; the compiler recognises the
Erlang <module> <function> send shape, recovers the module/function/arity
the same way codegen lowers the call, and matches them against the spec.
Each result is a Dictionary with three keys:
#class— the class whose method contains the call (the class object for an instance-side hit, the metaclass object for a class-side hit)#selector— the selector of the method that contains the call#line— the 1-based line number within the method source where the call appears
A method that calls the function multiple times produces one record per
occurrence. Iterates the navigation scope (allClasses) and walks both
instance-side and class-side method dictionaries (BT-2195), so stdlib and
user classes are covered on both. Returns an empty collection if no call
sites are found (not an error).
Examples
SystemNavigation ffiSitesFor: "lists:reverse"
// => [#{#class => SystemNavigation, #selector => ..., #line => 7}, ...]
SystemNavigation ffiSitesFor: "lists:reverse/1" // arity-qualified
SystemNavigation ffiSitesFor: "lists:noSuchFunctionXyzzy" // => []
Parse an FFI spec String into its components, raising on a malformed shape.
Returns a Dictionary #{#module => String, #function => String, #arity => Integer | #any}. The #arity value is the special Symbol
#any when the spec omits the /arity suffix (the conventional encoding
the underlying FFI accepts for "match any arity"), otherwise the parsed
non-negative Integer.
Accepts "module:function" and "module:function/arity". Raises a typed
error (kind #user_error) for any other shape: a missing/extra :, an
empty module or function, more than one /, or a non-numeric arity.
Raise the shared malformed-spec error for ffiSitesFor: / parseFfiSpec:.
Always raises (kind #user_error); declared -> Never so ^self raiseFfiSpecError: in parseFfiSpec: is not an Object return.
Append FFI call sites of module:function (constrained to arity unless
it is #any) found in any method of aScope to result. Returns the
(possibly extended) result list.
Internal helper for ffiSitesFor:. Iterates aScope methods, fetches each
method's source via >>, and asks the compiler to find matching FFI call
line numbers. Mirrors collectSendersFor:in:into:; the >> send is guarded
with respondsTo: so a scope for which >> is not yet supported (e.g.
metaclass-shaped registry entries) is silently skipped.
Append one record per matching FFI call site found in methodSource.
Internal helper for collectFfiSitesFor:function:arity:in:into:. Splits the
per-method FFI call out so the surrounding inject:into: body stays a
single expression — same shape as appendSendersIn:selector:class:methodSelector:into:.
Return a collection of {class, selector} records for every method
whose source text matches aRegex.
Source-text grep across the whole loaded class registry — answers "show me every method whose body mentions X." Each result is a Dictionary with two keys:
#class— the class that defines the method (the class object for an instance-side hit, the metaclass object for a class-side hit)#selector— the selector of the matching method
Iterates the navigation scope (allClasses) and walks both
instance-side and class-side method dictionaries (BT-2195). Methods
whose source is missing (e.g. generated primitives, methods registered
without source text) are skipped, not raised. One match per method
suffices — methodsMatching: does not enumerate every match position
within a single method.
The argument must be a compiled Regex instance. Callers that have a
pattern string should compile it explicitly via Regex from: ... unwrap; passing a String raises a typed error. Matches Pharo's
SystemNavigation >> #allMethodsWithSourceString: in spirit, but
requires an explicit regex object rather than guessing literal vs
regex from the input.
Performance: O(N x source-length). Fine for on-demand IDE search; not for hot live-highlight paths. A maintained index is a follow-up optimisation (see ADR 0033 / BT-2201).
Examples
pat := (Regex from: "ifTrue:") unwrap
SystemNavigation methodsMatching: pat
// => [#{#class => Counter, #selector => increment}, ...]
SystemNavigation methodsMatching:
(Regex from: "xyzzyNeverAppearsInAnyMethodBody") unwrap
// => []
Append {class, selector} records for methods of aScope whose source
matches aRegex to result. Returns the (possibly extended) result.
Internal helper for methodsMatching:. Iterates aScope methods,
fetches each via >>, and tests aRegex against the source. Methods
with no source (nil) — or classes whose method lookup is unsupported
(e.g. metaclass-shaped registry entries; see sendersOf:) — are
skipped silently.
Return a sorted, deduplicated list of selectors whose name contains
aPattern (case-insensitive substring match).
Powers omni-bar / Cmd-T "find any selector" surfaces in an IDE. Collects instance-side and class-side selectors, then filters by lowercase substring match.
Matching uses selectorString lowercase includesSubstring: aPattern lowercase, mirroring Pharo's SystemNavigation >> #allSelectorsContaining:.
Maintained index (ADR 0087, BT-2302)
The class-body selectors are read from the runtime-maintained xref methods
table (beamtalk_xref), populated at class-load time by codegen's baked
register_class/0 payload — one methods row per {class, side, selector} definition. This is a sub-millisecond ETS read in place of the
former methods / class methods probe over every class in the scope.
Miss policy. Mirrors sendersOf::
- Indexed selector rows whose class is no longer loaded are dropped silently (stale).
- A class the registry reports as loaded but that is absent from the index
falls back to the legacy
selectorsForClass:gather for that class only, and the runtime logs onexref_misswarning. The partition is computed runtime-side bybeamtalk_xref:defined_selectors_bt/0.
Raises an error if the argument is not a String, or if the pattern is empty (an empty pattern would match every selector and is almost certainly a programming error).
Returns [] when no selectors match.
Examples
SystemNavigation selectorsMatching: "append"
// => [#appendBinary:contents:, ...]
SystemNavigation selectorsMatching: "AppEnd"
// => [#appendBinary:contents:, ...] (case-insensitive)
SystemNavigation selectorsMatching: "noSelectorContainsThisXyzzy"
// => []
Return every selector defined on the given class: instance-side and class-side.
Internal helper for selectorsMatching:. Splits the per-class gather
out so the surrounding inject:into: body stays a single expression,
mirroring the collectSendersFor:in:into: / sendersOf: pairing
above.
Return a List of every selector that is sent somewhere in the loaded class registry but defined nowhere — the classic Smalltalk typo-finder.
Each result is a Dictionary with two keys:
#selector— the unimplemented selector (a Symbol)#sites— a List of site Dictionaries, one per send. Each site has:#class— the class whose method contains the send (class object for an instance-side hit, metaclass object for a class-side hit)#selector— the selector of the method that contains the send#line— the 1-based line number within that method's source
So a typo like self printOnStream: x (when printOnStream: is defined
nowhere) surfaces with a site pointing straight at the offending method,
letting an IDE jump the user to the mistake.
Index-backed design (ADR 0087, BT-2303)
Computes allSentSelectors − allDefinedSelectors, both sets read from the
runtime-maintained xref index (beamtalk_xref) rather than re-parsed:
- The defined set is the indexed
defined_selectors_btrows (instance- and class-side), unioned with the documentedruntimeProvidedSelectors. - The sent sites come from
all_sends_bt— one indexed row per send, carrying the sent selector, the containing method's owner / side / selector / line, and the receiver tag. Sends whose selector is in the defined set are dropped; the rest are grouped by selector into the result, sites resolved to#{#class, #selector, #line}records.
Miss policy (mirrors sendersOf: / selectorsMatching:). The index
is authoritative for loaded classes, but a miss must never become a wrong
answer:
- Indexed rows whose owning class is no longer loaded are dropped silently (stale), runtime-side.
- A class the registry reports as loaded but that is absent from the index
falls back to the legacy source-scan (
collectAllSendsIn:excluding:into:for sends,selectorsForClass:for defines) for that class only, and the runtime logs onexref_misswarning. The partitions are computed runtime-side bybeamtalk_xref:defined_selectors_bt/0andbeamtalk_xref:all_sends_bt/0.
Exclusions (and their limits)
doesNotUnderstand:args:— a class that defines the DNU overridedoesNotUnderstand:args:can legitimately receive arbitrary selectors viaself/super(the DNU handler interprets them dynamically), so sends toself/superinside such a class are not flagged. This is a coarse heuristic: it does not know the runtime receiver type, so it only suppressesself/supersends in the defining class, not sends to other instances of it. Proper receiver-type analysis is out of scope.perform:— the dynamic selector argument toperform:/perform:with:is a Symbol literal, never an AST send, so it is never collected in the first place (no special-casing needed).perform:itself is defined on Object, so it is in the defined set and never flagged.- Erlang FFI —
Erlang module …and(Erlang module) selector: …are Erlang function calls routed throughErlangModule'sdoesNotUnderstand:bridge, not Beamtalk message sends. The compiler tags such sends with receiver kind#erlang_ffi; they are dropped wholesale (otherwise every FFI module name and FFI function name would be a false positive). This is exact, not heuristic: the receiver is a staticErlang …chain in the AST. - Runtime-provided selectors — a small documented set of selectors
that are real and resolvable at runtime but are not surfaced through the
compile-time
methodsdictionary (e.g. codegen-inlined pseudo-selectors or primitives registered under a different name). SeeruntimeProvidedSelectors.
Performance
Two sub-millisecond ETS reads (defined_selectors_bt + all_sends_bt),
in place of the former per-call AST walk over every method source (same
migration as sendersOf:; see docs/development/benchmarks.md).
Returns [] when the registry is clean (modulo the documented
exclusions). Source-less methods contribute neither sends nor flags,
exactly as in sendersOf:.
Examples
SystemNavigation unimplementedSelectors
// => [#{#selector => #printOnStream:, #sites => [#{#class => Foo, #selector => bar, #line => 3}]}]
Union two fallback-class lists into a List of class-name Symbols, dropping
duplicates. Internal helper for the composite queries: the defined-set and
sent-set _bt reads each compute their own miss partition, so a class
missing from the index can appear in both — the source-scan fallback must
visit it exactly once.
Add each indexed defined_selectors_bt row's #selector Symbol to the Set
result. Returns the (possibly extended) Set. The explicit -> Set(Symbol)
return anchors element-type inference for the defined-set accumulator
(mirrors indexedSelectorsFrom:into:), keeping acc strongly typed rather
than Dynamic (BT-2303).
Build the set of scope keys (ownerName for an instance-side scope,
ownerName ++ " class" for a class-side scope) whose methods include
doesNotUnderstand:args: — the classes the coarse DNU heuristic must
suppress self/super sends in (see unimplementedSelectors). Returns the
(possibly extended) Set of String keys.
The handler set is read from the SAME indexed defined_selectors_bt rows
the defined set comes from (a row whose #selector is
doesNotUnderstand:args: marks its owner/class_side scope), then
extended with the loaded-but-unindexed fallback scopes probed directly via
methods includes: (mirroring the legacy per-scope check). Keying on
owner + side keeps the side-specific semantics of the source-scan path:
instance-side DNU suppresses instance-side sends, class-side DNU suppresses
class-side sends.
The DNU-scope key for an xref owner-tag / class-side pair: the owner name
String for an instance-side scope, suffixed with " class" for a
class-side scope. Matches dnuScopeKeyFor: so an indexed scope and a
Behaviour scope for the same class+side produce the same key.
The DNU-scope key for a Behaviour scope: its name String, which already
carries the " class" suffix for a metaclass (so Counter class name is
"Counter class"). The fallback-scope counterpart of
dnuScopeKeyForOwner:classSide:.
Group indexed send rows (beamtalk_xref:all_sends_bt/0) by their sent
selector into result (selector -> [sites]), dropping any send that is
excluded. Returns the (possibly extended) Dictionary.
Internal helper for unimplementedSelectors. Each row is a Dictionary
with atom keys #sent (the sent selector), #owner (class-name Symbol),
#class_side (Boolean), #method (the containing method's selector),
#line (positive Integer), and #recv (the receiver tag #self / #super
/ #erlang_ffi / #other). A send is dropped when its #sent selector is
in excluded, when #recv is #erlang_ffi, or when its scope handles DNU
and #recv is #self / #super — the same three exclusions recordSend:…
applies on the source-scan path. A send whose owner no longer resolves
(class removed since the rows were read) is dropped too (BT-4111).
Selectors that are genuinely resolvable at runtime but are NOT surfaced
through the compile-time methods dictionary, so unimplementedSelectors
would otherwise flag them as typos.
Keep this list small and documented — each entry must be a real framework
selector, never a way to silence an actual typo. Empirically derived by
running unimplementedSelectors against the live stdlib and confirming
each entry is inlined / registered under a different name.
(Currently empty: the stdlib comes back clean after the structural
doesNotUnderstand: and perform: exclusions. Entries are added here
with a comment explaining the runtime mechanism that provides them.)
Append unimplemented-send sites found in any method of aScope (a class
or metaclass) to the grouping Dictionary result, dropping any send whose
selector is in excluded. Returns the (possibly extended) Dictionary.
Internal helper for unimplementedSelectors. Mirrors
collectSendersFor:in:into: but threads a grouping Dictionary
(selector -> [sites]) instead of a flat List, and asks the compiler for
EVERY send (allSendsIn:) rather than one selector's senders.
Guards the >> send with respondsTo: so a scope for which >> is not
yet supported is skipped rather than aborting the whole walk.
Append one grouped site per unimplemented send found in methodSource.
Internal helper for collectAllSendsIn:excluding:into:. Splits the
per-method FFI call out so the surrounding inject:into: body stays a
single expression — same shape as
appendSendersIn:selector:class:methodSelector:into:.
For each send tuple {sentSel, line, recv} returned by allSendsIn:,
the send is recorded in the grouping Dictionary unless:
sentSelis inexcluded(already defined, or runtime-provided), or- the owner defines
doesNotUnderstand:and the receiver is#self/#super(the coarse DNU heuristic — seeunimplementedSelectors).
Add a single send site to the grouping Dictionary, applying the defined /
runtime-provided and doesNotUnderstand: exclusions. Returns the
(possibly extended) Dictionary unchanged when the send is excluded.
Internal helper for appendAllSendsIn:.... Splitting the per-send
decision out keeps the surrounding inject:into: body a single
expression.
Return a List of dead-method candidates — selectors that are DEFINED on
some class but SENT nowhere in the loaded class registry. The conservative
inverse of unimplementedSelectors.
Each result is a Dictionary with two keys:
#class— the class object for an instance-side definition, or the metaclass object for a class-side definition (mirrors how the other navigation queries report#class)#selector— the defined-but-unsent selector (a Symbol)
A diagnostic, not a delete list
This is deliberately framed as "worth a look", NOT "definitely dead". A static source scan cannot see every way a method is reached, so several categories of genuinely-live methods are invisible to it. Rather than flag those as false positives, the query excludes the known-invisible categories up front (see Exclusions). What remains is a high-signal set of candidates for an IDE "unused methods" pane — each one still warrants human judgement before deletion.
Index-backed design (ADR 0087, BT-2303)
Computes allDefinedSelectors − allSentSelectors. The sent set is read
from the runtime-maintained xref index via
beamtalk_xref:all_sent_selectors_bt/0 (the distinct set of selectors sent
somewhere, Erlang-FFI sends already excluded runtime-side) rather than
re-parsed, unioned with the loaded-but-unindexed fallback classes'
source-scanned sends. The defined
candidates are built by walking cls methods (instance-side, owner cls)
and cls class methods (class-side, owner cls class) over the live class
registry — a reflective method-dictionary read, NOT a source re-parse — so
each candidate remembers its owning class object for the #class field.
A candidate survives into the result only if its selector is absent from
the sent set and survives every exclusion below.
Miss policy (mirrors sendersOf:). Indexed sent-selector rows whose
owning class is no longer loaded are dropped silently (stale), runtime-side;
a class the registry reports as loaded but absent from the index has its
sends source-scanned (collectSentSelectorsIn:into:) for that class only,
and the runtime logs one xref_miss warning. The partition is computed
runtime-side by beamtalk_xref:all_sent_selectors_bt/0.
Exclusions (and their limits)
- Erlang FFI sends are NOT counted as Beamtalk uses.
Erlang module …/(Erlang module) sel: …are Erlang function calls (tagged#erlang_ffiat the AST), so the "selectors" they carry are Erlang module/function names, not Beamtalk selectors. They are dropped from the sent set wholesale — counting them would let an Erlang function name that happens to match a Beamtalk selector spuriously mark that selector as used.#self/#super/#othersends ARE counted: a self-send offoomeansfoois used. - Runtime-called overrides (
runtimeCalledSelectors) — framework selectors the runtime invokes without a source-visible send (lifecycle hooks, the DNU handler, display/hash protocols). Overrides of these are never flagged. See that method for the list and the per-entry rationale. - TestCase test-runner methods — for
TestCaseand any class that inherits from it (anincludesBehaviour: TestCasecheck, self-inclusive), the methodssetUp/tearDownand everytest…method are invoked reflectively bybeamtalk_test_case, never via a source send, so they are excluded. The pattern exclusion is scoped to the TestCase hierarchy specifically, so a normal class with an unrelated method literally namedtest…is still eligible to be flagged. - Primitive / intrinsic methods — a method whose source is
nilor whose body contains@primitive/@intrinsicis implemented in (or dispatched from) the runtime and is reachable in ways the source scan cannot see, so it is excluded. This is a heuristic: it keys off the@primitive/@intrinsicannotation text in the method source rather than a structural AST flag. perform:is invisible. A selector reached only viaself perform: #foo/perform:with:is a Symbol literal, never an AST send, so it is never added to the sent set — such a method WILL appear as a false positive. This is an inherent limit of a static scan; no special casing is attempted.
Performance
One sub-millisecond ETS read (all_sent_selectors_bt) for the sent set
plus the reflective defined-candidate walk, in place of the former per-call AST walk over every method source
(same migration as sendersOf:; see docs/development/benchmarks.md).
Returns [] when nothing qualifies. Note that a real stdlib has many
public selectors that are part of the API surface but sent nowhere in the
library itself, so the live result is expected to be non-empty.
Examples
SystemNavigation unusedSelectors
// => [#{#class => Foo, #selector => #neverCalledHelper}, ...]
Add each indexed all_sent_selectors_bt selector Symbol to the Set
result. Returns the (possibly extended) Set. Each indexed element is
Dynamic (it comes through the FFI partition map), so the explicit
-> Set(Symbol) return anchors element-type inference for the sent-set
accumulator (mirrors definedSetFromIndex:into:), keeping acc strongly
typed rather than Dynamic (BT-2303).
Selectors the runtime / framework invokes WITHOUT a source-visible Beamtalk
send, so an override of one would otherwise look unused to unusedSelectors.
Keep this list small and documented — each entry must be a real selector
the runtime dispatches on its own; never a way to silence a genuinely dead
method. Each name below was verified against the live stdlib (e.g. the DNU
override is doesNotUnderstand:args:, NOT the Smalltalk-classic
doesNotUnderstand:; Beamtalk has no printOn: or = selectors).
initialize— Actor lifecycle hook called automatically after spawn (seeActor >> #initialize).terminate:— Actor lifecycle hook called by the runtime on shutdown (seeActor >> #terminate:).doesNotUnderstand:args:— the DNU handler, invoked by the message dispatch runtime when a selector is not understood (ProtoObject, Erlang, ErlangModule, TimeoutProxy define it).printString— invoked by the REPL / transcript display path to render a value; an override is reached through display, not a source send.displayString— invoked by user-facing display surfaces.inspect— invoked by the inspector surface (ADR 0095):anObject inspectopens anInspectorcursor, which the REPL/MCP surfaces render.hash— invoked by hashed collections (Set / Dictionary) when storing or comparing elements, not via a source-level send.handleInfo:/onLinkedExit:reason:—Serverhooks the runtime calls for raw messages and linked-process exits.asJson—JsonRepresentablehook called by the JSON encoder.childSpecs/strategy/maxRestarts/restartWindow/childClass/maxChildren/childShutdown— supervisor configuration hooks read by the supervisor runtime when it starts.supervisionSpec— class-side hookbeamtalk_supervisor_specsends.equals:— sent bybeamtalk_equalityfromincludes:/=.supervisionPolicy/isSupervisor/secretState/secretSelectors— class-side hooks the runtime queries on a class.
Add every selector sent in any method of aScope (a class or metaclass)
to the Set result, EXCLUDING Erlang-FFI sends. Returns the (possibly
extended) Set.
Internal helper for unusedSelectors. Mirrors collectSendersFor:in:into:
but accumulates into a Set and asks the compiler for EVERY send
(allSendsIn:) rather than one selector's senders. Splitting it out keeps
the surrounding inject:into: body a single expression.
Guards the >> send with respondsTo: so a scope for which >> is not yet
supported is skipped rather than aborting the whole walk, and guards a nil
method source (a sourceless method, e.g. a primitive) so
addSentSelectorsIn: always receives a String.
Add each non-FFI sent selector found in methodSource to the Set result.
Returns the (possibly extended) Set.
Internal helper for collectSentSelectorsIn:into:. Splits the per-method
FFI call out so the surrounding inject:into: body stays a single
expression. For each send tuple {selector, line, recv} from allSendsIn:,
the selector is added unless the receiver kind is #erlang_ffi (an Erlang
call, not a Beamtalk send — see unusedSelectors).
Append a #{#class, #selector} record for every locally-defined selector
of aScope that is unused, recording owner as the reported #class.
Returns the (possibly extended) result List.
Internal helper for unusedSelectors. aScope is the scope to iterate
(cls for instance-side, cls class for class-side); owner is the class
object to report (the same value, but threaded separately to match the
#class reporting convention and keep the inject:into: body a single
expression). A selector is reported only when none of the exclusions in
unusedSelectors apply.
Whether the test-runner pattern applies is decided once per scope via
includesBehaviour: TestCase, so it is not recomputed per method. Using
includesBehaviour: (self-inclusive) rather than inheritsFrom: (strict)
matters: TestCase itself defines setUp / tearDown, which the runner
invokes reflectively just like on a subclass, so they must be excluded on
the base class too.
Add a single #{#class => owner, #selector => methodSel} record to
result unless methodSel is excluded. Returns result unchanged when
the selector is excluded.
Internal helper for collectUnusedFor:owner:sent:excluded:into:. Splitting
the per-selector decision out keeps the surrounding inject:into: body a
single expression. A selector is excluded when it is sent somewhere, is a
runtime-called override, is a TestCase test-runner method, or is a
primitive / intrinsic (see unusedSelectors).
Whether aSelector is invoked by the BUnit test runner rather than via a
source send: setUp, tearDown, or any selector whose name starts with
test. Only meaningful for selectors in the TestCase hierarchy — the caller
gates this behind includesBehaviour: TestCase.
Whether the method methodSel on aScope is a primitive / intrinsic, and
therefore reachable in ways the source scan cannot see. Treated as such
when the source is nil (no AST-visible body) or contains the
@primitive / @intrinsic annotation text. Heuristic — see
unusedSelectors.
Guards the >> send with respondsTo: (a scope without >> support is
treated as primitive — its body cannot be inspected so it is conservatively
excluded rather than flagged).
Indexed/fallback partition of implementor rows for aSelector (ADR 0087).
Indexed/fallback partition of sender call sites for aSelector (ADR 0087).
Indexed/fallback partition of reference sites for aSymbol (ADR 0087).
Indexed/fallback partition of defined-selector rows (ADR 0087).
Indexed/fallback partition of every send site (ADR 0087).
Indexed/fallback partition of the distinct sent-selector set (ADR 0087).
Resolve a class-name tag to the class/metaclass object, or nil.
The still-registered classes among names (BT-4095), resolved from the
registry snapshot.
The registered name of aClass's class, or nil once it is removed
(BT-4095). Metadata only; never a send to the class process.
Every message send (with line + receiver tag) in aSource.
Line numbers of aSelector sends within aSource.
Line numbers of references to class aName within aSource.
Announcement emission sites (line + resolved class name) in aSource.
Line numbers reading field aSym within aSource.
Line numbers writing field aSym within aSource.
Line numbers of FFI call sites matching aModule:aFunction/anArity
within aSource.
The metaclass display tag (Foo -> Foo class) for aName.
Inherited Methods
From Object
Return the class of the receiver.
Examples
42 class // => Integer
"hello" class // => String
Test if the receiver is nil. Returns false for all objects except nil.
Examples
42 isNil // => false
nil isNil // => true
Test if the receiver is not nil. Returns true for all objects except nil.
Examples
42 notNil // => true
nil notNil // => false
If the receiver is nil, evaluate nilBlock. Otherwise return self.
_nilBlock is never evaluated on this Object-level definition (only
UndefinedObject's override calls it, with Block(R) -> R), so R is
unconstrained here — parameterizing it still documents the zero-arg
shape without implying this branch produces R (BT-2834).
Examples
42 ifNil: [0] // => 42
nil ifNil: [0] // => 0
If the receiver is not nil, evaluate notNilBlock with self.
Left as a bare Block deliberately (BT-2834): notNilBlock is invoked
one-arg with self and its result becomes the method's own result, so
a precise signature needs a Self-in-Block(...) type-arg form
(Block(Self, R) -> R) with no precedent elsewhere in stdlib. The type
checker doesn't consult this declared signature for ifNotNil: anyway
— it narrows the block's parameter from the receiver's own type via
infer_args_for_if_not_nil in inference.rs (BT-2046), independent of
this stdlib declaration.
Examples
42 ifNotNil: [:v | v + 1] // => 43
nil ifNotNil: [:v | v + 1] // => nil
If nil, evaluate nilBlock; otherwise evaluate notNilBlock with self.
Bare Block params here (unlike UndefinedObject's Block(R) -> R
override, BT-2824) are intentional, not an oversight: the type checker
never consults this declared signature for these two selectors — it
reads the block arguments' actual inferred return types directly
(if_nil_branch_union_ret_ty in inference.rs, BT-2047) since a bare
-> R here can't express "whatever the block returns" without a
Self-in-Block(...) type-arg form with no precedent elsewhere in
stdlib.
Examples
42 ifNil: [0] ifNotNil: [:v | v + 1] // => 43
nil ifNil: [0] ifNotNil: [:v | v + 1] // => 0
If not nil, evaluate notNilBlock with self; otherwise evaluate nilBlock.
See ifNil:ifNotNil: above — the bare Block params are intentional.
Examples
42 ifNotNil: [:v | v + 1] ifNil: [0] // => 43
nil ifNotNil: [:v | v + 1] ifNil: [0] // => 0
Answer the result of evaluating aBlock with the receiver
(ADR 0145 § 2, named after Elixir's Kernel.then/2).
The escape hatch for putting a value somewhere other than the receiver
of the next message, typically after |>. It is an ordinary message,
so it also works without |>. Put |> in front of a then: that
follows a keyword message: without it, xs inject: 0 into: [...] then: [...] is one inject:into:then: send.
The aBlock param is deliberately untyped. Every class inherits this
method, so a declared Block would make each user class's own then:
with another parameter type (a parser combinator's then: next :: Parser, say) draw an override-incompatibility warning. The type checker
does not consult this signature for a literal block anyway: it types the
block's parameter as the receiver's type and answers the block's result
type (infer_args_for_then in inference/blocks.rs, BT-4515).
then: is not inlined and not sealed. A class that defines its own
then: (a promise, say) keeps it. Because it is a message, on an actor
receiver the block runs in the actor's process, so a block that sends
back to the calling actor (or, through TimeoutProxy, to the proxy)
fails with deadlock_detected or a call timeout; on a class receiver
it runs in the caller (ADR 0142). A block passed to it that assigns a captured local is an
escaping block (ADR 0133), a compile error: bind the value to a temp
local instead. TimeoutProxy forwards then: to its target, so the
target's own then: runs if it has one.
Examples
3 then: [:x | x * x] // => 9
#(1, 2, 3) collect: [:x | x * 2] |> then: [:xs | xs size * 10] // => 30
Return the developer-readable (Debug) string representation.
printString is the Debug protocol (ADR 0094): the self-describing,
structural form used by the REPL, logs, and by any other printString
that nests this object. It is the REPL default — evaluating an expression
shows its printString.
This default returns the bare class name (no a/an article — the
old "a ClassName" form was dropped in ADR 0094). Value overrides it
with the structural ClassName(field: value, ...) form, actors render as
Actor(ClassName, pid), supervisors as Supervisor(ClassName, pid) /
DynamicSupervisor(ClassName, pid), and primitive types (Integer, String,
List, …) override it with their own richer output. Authors rarely override
printString directly — the default is derived.
Examples
42 printString // => "42"
Return the user-facing (Display) string representation.
displayString is the Display protocol (ADR 0094): the human-facing
form. It is the hook the language pulls during string interpolation —
every {...} segment renders via the value's displayString. Developers
rarely call it directly; they override it when a value has a natural
human rendering (e.g. Money → $10.50, where printString would still
show the Debug form).
It defaults to printString, so most types need no override. String
and Symbol demonstrate the split: "hi" printString → "\"hi\""
(quoted, Debug) while "hi" displayString → "hi" (plain, Display);
likewise #foo drops its # prefix under displayString.
displayString is not part of the Printable protocol (deferred per
ADR 0094 §5).
Examples
42 displayString // => "42"
Open a navigable Inspector cursor on the receiver.
ADR 0095 Phase 3 (BT-2504). inspect is repurposed from -> String
(the ADR-0094 deferral) to the verb that produces an Inspector — a
live, immutable cursor for drilling into the object (Inspector on: self).
anObject inspect is the shorthand; Inspector on: anObject is the
explicit spelling. The cursor exposes fields/at:/path/refresh/
printString (an indented text tree) and asDictionaries (the MCP/browser
wire form); see Inspector.
This is a breaking change: code that used inspect for its old
String result must switch to printString (the structural Debug string,
ADR 0094) — a transitional lint flags inspect used directly in ++/
string position.
Examples
42 inspect kind // => #value
(Point x: 3 y: 4) inspect fields size // => 2
(Point x: 3 y: 4) printString // => "Point(x: 3, y: 4)" (the old inspect string)
Return the receiver itself. Useful for cascading side effects.
Examples
42 yourself // => 42
Return a hash value for the receiver.
Examples
42 hash
Test value equality — the overridable counterpart to =:=.
Defaults to =:= (Erlang structural term equality), so for most classes
the two agree. Unlike =:=, this is an ordinary message send, so a class
whose logical value is not its representation can override it: a
persistent structure whose shape depends on construction history, a
timestamp that should compare by instant rather than by wall-clock fields,
or a type with a normalising form. =:=, =/=, == and /= are lowered
straight to Erlang BIFs (ADR 0002) and cannot be overridden — the compiler
rejects any attempt (BT-2997).
What honours it
The linear scans: includes: on Collection, List, Array and
Dictionary (which searches values), plus List>>indexOf: and
TestCase>>assert:equals:.
Contract
An override must agree with =:= wherever =:= holds — a =:= b must
imply a equals: b. It may only make more values equal, never fewer.
The scans above rely on this: each tries raw =:= first and dispatches
only on a miss, so a fast-path hit is always a genuine equals: hit.
Caveat
Set, Dictionary keys, and List>>unique decide identity in the VM
with raw =:=, never through this method — keying and deduplication need
an order or a hash that a user-defined equals: cannot supply. A class
that overrides equals: still deduplicates by representation when used
as a key or element. Normalise the representation if that matters.
Examples
42 equals: 42 // => true
42 equals: 42.0 // => false (defaults to strict `=:=`)
"ab" equals: "ab" // => true
Test if the receiver responds to the given selector.
Examples
42 respondsTo: #abs // => true
Return the names of fields.
Examples
42 fieldNames // => #()
Return the value of the named field.
Left without a declared return type deliberately (BT-2834 pattern,
see Block>>value): the field's actual value can be any type, and
callers routinely send it further messages ((self fieldAt: #x) + 1)
that a fixed -> Object would statically reject.
Examples
object fieldAt: #name
Set the value of the named field. Answers value.
Examples
object fieldAt: #name put: "Alice"
Test whether the receiver has the named field. Never raises — the
non-raising counterpart to fieldAt:, in particular for a late
slot (ADR 0124): fieldAt: raises UninitializedStateError reading
an unassigned late slot, hasField: is the question to ask first.
Examples
c := CodexClient start: "/tmp/ws" config: cfg onEvent: nil
c hasField: #proc // => false — declared `late`, not yet assigned
c launch
c hasField: #proc // => true
42 hasField: #anything // => false — primitives have no fields
Return a late field to the unassigned state (ADR 0124), so it can be
assigned again (e.g. re-acquiring a resource). Joins fieldAt:/
fieldAt:put:/fieldNames in ADR 0035's field-prefixed reflection
family. Returns self.
Examples
c clearField: #proc
c hasField: #proc // => false — relaunchable
Send a unary message dynamically.
Declared -> Dynamic explicitly (BT-4044): the invoked method's
return type is unknown statically, so the reflective result really
is unknown — and unlike the BT-2834 unannotated pattern (see
fieldAt: above), an explicit Dynamic does not warn at call
sites in typed classes. Chained sends on the result still check
dynamically, as before.
Examples
42 perform: #abs // => 42
Send a message dynamically with arguments.
See perform: above for why the return type is declared Dynamic.
Examples
3 perform: #max: withArguments: #(5) // => 5
Raise an error indicating this method must be overridden by a subclass.
Examples
self subclassResponsibility
Raise an error indicating this method has not yet been implemented.
Use this for work-in-progress stubs. Distinct from subclassResponsibility,
which signals an interface contract violation.
Examples
self notImplemented
Send aValue to Transcript without a trailing newline.
Outside an interactive workspace this is a Logger notice (ADR 0129 §5).
Examples
42 show: "value: "
Send aValue to Transcript followed by a newline.
Outside an interactive workspace this is a Logger notice (ADR 0129 §5).
Examples
42 showCr: "hello world"
Test if the receiver is an instance of aClass or any of its subclasses.
For class-object receivers, follows Smalltalk semantics: self class
is the metaclass, so the check walks the parallel metaclass hierarchy.
The parallel chain is grounded at ProtoObject class superclass == Class
(ADR 0036), so the metaclass tower merges into the instance-side
Class → Behaviour → Object → ProtoObject chain. As a result,
Integer isKindOf: Object and Integer isKindOf: Class both return true.
Examples
42 isKindOf: Integer // => true
42 isKindOf: Object // => true
#foo isKindOf: Symbol // => true
#foo isKindOf: String // => false
Integer isKindOf: Number // => false (metaclass chain, not instance chain)
Integer isKindOf: Number class // => true (Number class is in the parallel chain)
Integer isKindOf: Object // => true (grounded — Object is reachable via the metaclass tower)
Integer isKindOf: Class // => true (Integer class inherits from Class)
Raise an error with the given message.
Examples
self error: "something went wrong"
Delegate message dispatch to the backing Erlang module (ADR 0101, BT-2720).
This method is a sentinel — a plain Object has no backing Erlang module,
so calling delegate raises an Error at runtime. Stateless Objects
declared with native: have their self delegate method bodies rewritten
by the compiler's codegen phase to call the backing module directly, so the
sentinel is never reached on a native: class.
Unlike Actor's delegate (visible only to Actor subclasses), this
Object-base sentinel is visible to every class, so delegate is a
reserved selector on the Object protocol.
Examples
42 delegate // => ERROR: delegate called on a non-native Object
From ProtoObject
Test value equality (Erlang ==, non-strict — 1 == 1.0 is true).
Examples
42 == 42 // => true
"abc" == "abc" // => true
Test value inequality (negation of ==).
Examples
1 /= 2 // => true
42 /= 42 // => false
Test strict value equality (Erlang =:= — 1 =:= 1.0 is false, unlike ==).
Every object supports this at runtime (it lowers directly to Erlang's
=:= operator regardless of receiver type, ADR 0002) — declared here,
once, so it is visible in method listings/completions/respondsTo: for
every class, not just the handful (Integer, String, ...) that
separately redeclare it with a narrower, class-typed other for
documentation purposes.
Examples
1 =:= 1 // => true
1 =:= 1.0 // => false (strict — different types)
(Dictionary new) =:= #{} // => true
Test strict value inequality (negation of =:=).
Examples
1 =/= 1.0 // => true (strict — different types)
1 =/= 1 // => false
Return the class of the receiver.
Examples
42 class // => Integer
"hello" class // => String
Handle messages the receiver does not understand. Override for custom dispatch.
No declared return type (BT-2834 pattern, see Object>>fieldAt:): a
custom override can return any type, and callers chain further sends
on the result that a fixed -> Object would statically reject.
Examples
42 unknownMessage // => ERROR: does_not_understand
Send a message dynamically with an arguments list.
Sent to a class, the class method runs in the caller's process, exactly
as the same send written out would, for every selector that is not
process-bound (new, spawn, startLink, ...; ADR 0142, ADR 0153).
Examples
42 perform: #abs withArguments: #() // => 42
Send a message dynamically with an arguments list and explicit timeout.
The timeout (in milliseconds or #infinity) applies to the gen_server:call
when the receiver is an actor. For value types, timeout is ignored.
Examples
actor perform: #query withArguments: #(sql) timeout: 30000