Skip to content

Add protocol-impls and multimethod-dispatch-values#401

Merged
bbatsov merged 1 commit into
masterfrom
who-implements
Jun 24, 2026
Merged

Add protocol-impls and multimethod-dispatch-values#401
bbatsov merged 1 commit into
masterfrom
who-implements

Conversation

@bbatsov

@bbatsov bbatsov commented Jun 24, 2026

Copy link
Copy Markdown
Member

The foundational piece for a "who-implements" feature in CIDER (clojure-emacs/cider#1969, whose original design sketch called for exactly this middleware).

orchard.xref/protocol-impls returns the types implementing a protocol. It covers both extend/extend-type/extend-protocol targets (via extenders) and inline defrecord/deftype implementers - the latter found by scanning the loaded-class cache for the protocol's generated interface (the same DynamicClassLoader cache fn-deps already uses). Each entry carries a source location when one is resolvable (records/types expose it through their ->Name factory var; Java targets have none).

orchard.xref/multimethod-dispatch-values returns a multimethod's dispatch values.

Only loaded code is visible, consistent with the rest of orchard.xref. Per-defmethod source locations aren't included - those methods are anonymous fns with no runtime metadata, so they'd need bytecode line-table reading; that's left for a follow-up.

orchard.xref/protocol-impls returns the types implementing a protocol - both
extend/extend-type/extend-protocol targets and inline defrecord/deftype
implementers (found by scanning the loaded-class cache for the protocol's
generated interface) - each with a source location where one is resolvable.
orchard.xref/multimethod-dispatch-values returns a multimethod's dispatch
values.

These back a forthcoming cider-nrepl "who-implements" op, the foundational
middleware envisioned in clojure-emacs/cider#1969.
@bbatsov bbatsov merged commit be64532 into master Jun 24, 2026
12 checks passed
@alexander-yakushev alexander-yakushev deleted the who-implements branch July 4, 2026 18:00
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