Description
Summary
The ObjC member-call resolver treats a @protocol declaration as a candidate type for a message receiver. A protocol is a contract, never a receiver, and ObjC keeps protocol and class names in separate namespaces — so this is wrong in both directions:
- protocol alone in the corpus → a fabricated
callsedge at confidence EXTRACTED / 1.0 pointing into the protocol's method declaration; - protocol + a same-named class → two candidates trip the single-definition god-node guard, so a call that resolves fine without the protocol produces no edge at all.
Same-named protocol/class pairs are idiomatic ObjC (@protocol Locking + class Locking, Reloading/Reloadable naming, and every <Foo>/Foo pair in a delegate-heavy codebase), so a real corpus gets both a false edge and a missing edge from the same root cause.
graphifyy 0.9.38 (v8 @ 10ad921), Python 3.12, macOS.
Reproduction
A. Protocol only → fabricated edge
Reload.h
@protocol Reload <NSObject>
- (void)reload;
@endWidget.h
#import "Reload.h"
@interface Widget : NSObject
- (void)go;
@endWidget.m
#import "Widget.h"
@implementation Widget
- (void)go { [Reload reload]; }
@end[Reload reload] is not a real call — Reload is a protocol, it has no +reload. Expected: no edge (nothing to type the receiver to). Actual:
calls '-go' -> '-reload' EXTRACTED L3
src=..._widget_widget_go
tgt=..._reload_reload_reload <- Reload.h, the PROTOCOL's declaration
B. Protocol + same-named class → the real edge disappears
Locking.h
@protocol Locking <NSObject>
- (void)lock;
@endLockingImpl.h
@interface Locking : NSObject
+ (void)lock;
@endLockingImpl.m implements +lock; Runner.m calls it:
#import "LockingImpl.h"
@implementation Runner
- (void)run { [Locking lock]; }
@endExpected -run -> +lock. Actual: zero calls edges. Dumping the resolver's type index shows why:
type_def_nids['locking']:
'<Locking>' tmp_iss_proto_locking_locking <- the protocol
'Locking' tmp_iss_proto_lockingimpl_locking <- the real class
len = 2 (god-node guard requires exactly 1)
Delete Locking.h and the edge comes back. The protocol's mere presence removes it.
Root cause
The ObjC extractor labels a protocol node <Name>:
# graphify/extractors/objc.py:264
add_node(proto_nid, f"<{name}>", line)_resolve_objc_member_calls builds its receiver-type index with a key that strips every non-alphanumeric character:
# graphify/extract.py:3311
def _key(label: str) -> str:
return re.sub(r"[^a-zA-Z0-9]+", "", str(label)).lower()
...
# graphify/extract.py:3316-3321
for n in all_nodes:
if n.get("source_file") and n.get("id") in contained and _is_type_like_definition(n):
type_def_nids.setdefault(_key(n.get("label", "")), []).append(n["id"])So <Locking> and Locking both key to locking. The angle brackets — the only thing distinguishing a protocol from a class at this layer — are exactly what _key discards. grep -n 'f"<{' graphify/extractors/objc.py returns a single hit (line 264), so the <X> label shape is unique to ObjC protocols and can be tested for without ambiguity.
_is_type_like_definition cannot be the place to fix this: it has 7 call sites spanning the stub-binding pass plus Swift/Python/C++/ObjC/C#/Java, and other languages legitimately want protocol-like nodes as type candidates.
Fix
Patch is up as #2500 against v8 (opened 2026-08-06, no CI run — external PRs sit at action_required). It excludes <Name>-labelled nodes from this resolver's receiver-type index only; protocols stay valid implements targets and valid stub-rewire targets, and the other six _is_type_like_definition consumers are untouched.
tests/test_objc_member_calls.py, 3 tests, each positive assertion paired with a decoy that must stay unresolved: 2 fail on v8 without the patch, all 3 pass with it. Full suite green, uv.lock untouched.
Happy to have it reimplemented however you prefer — the reproduction above is the part that matters.
Note
Related but independent: an ObjC category also mints a duplicate class node and trips the same guard (filed separately, patch in #2501). A corpus with both a category and a same-named protocol needs both fixes to clear the guard.
Activity
xiongjianxu commentedon Aug 10, 2026
Patch for this is in #2500 (base
v8). Note the PR shows no CI result — external PRs land inaction_requiredand need a maintainer to approve the workflow run; the suite is green locally (uv run --frozen pytest tests/ -q, plus the fivetools.skillgengates,uv.lockuntouched).xiongjianxu commentedon Aug 10, 2026
For anyone triaging the ObjC member-call pass together: a third, independent gap in the same
pass is now filed as #2591 — a
@propertyor ivar receiver ([self.bar doIt],[_ivarBar doIt]) can never be typed, becauseobjc_type_tableholds only method-body localdeclarations and the raw-call gate admits only an
identifierreceiver. That one is aboutmissing receiver types rather than colliding type candidates, so it needs a separate fix,
but all three surface in the same resolver.
fix(objc): protocol not a receiver type, category fold, property/ivar…
fix(extract): affected traverses in-function dynamic imports; Python …
safishamsi commentedon Aug 10, 2026
Fixed in v0.9.39. A
@protocoldeclaration (labeled<Name>) is now excluded from the receiver-type index, so it no longer collides with a same-named class and mis-resolves or fabricates a member call. Thanks @xiongjianxu for the fix (PR #2500).Merge upstream/v8 (v0.9.39) into chore/sync-upstream-0939
Merge upstream 'v8' (v0.9.39) into upstream-fix/member-call-resolver-…
fix(objc): protocol not a receiver type, category fold, property/ivar…
fix(extract): affected traverses in-function dynamic imports; Python …