Skip to content

fix(edge_builder): restrict same-file this-dispatch fallback to caller's own class #1324

@carlos-alm

Description

@carlos-alm

Deferred from PR #1308 review (Greptile).

In crates/codegraph-core/src/edge_builder.rs, the same-file method fallback for this/self/super receivers (around line 445) scans all methods in the file whose name ends with .methodName. When a file contains multiple unrelated classes (e.g. Shape, Calculator, Formatter), this.area() inside Shape.describe can match Calculator.area and Formatter.area too, producing false-positive call edges.

The TypeScript CHA post-pass (runChaPostPass) has an RTA filter after the fact, but the Rust path has no equivalent guard — all matched methods are returned and committed as edges.

Suggested fix: Before falling through to the full-file scan, first try restricting to the caller's own class name as a prefix (e.g. require n.name.starts_with("ClassName.")), only broadening to all same-file methods when no caller-class-scoped match is found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions