Skip to content

follow-up: setMethod/setGeneric should emit method call edges instead of duplicate definitions in both engines (R) #1109

@carlos-alm

Description

@carlos-alm

Deferred from PR #1102 review.

Original reviewer comment: #1102 (comment)

Context:
Greptile flagged that the R extractor's handle_set_generic function is invoked for both setGeneric and setMethod, producing two function definition nodes for the same generic name in idiomatic S4 code:

setGeneric("greet", function(x) standardGeneric("greet"))
setMethod("greet", "Person", function(x) ...)

Both engines (native Rust and WASM/JS) have this behavior — src/extractors/r.ts shares the same single handler for both. Fixing in only one engine would create a parity gap.

Proposed fix:

  • setGeneric continues to emit a function definition node.
  • setMethod either:
    • emits a call edge to the generic instead of a new definition, or
    • emits a definition node with a different kind (e.g. method) so the resolver can dedupe by (name, kind).

Must be applied to both src/extractors/r.ts and crates/codegraph-core/src/extractors/r_lang.rs simultaneously to preserve engine parity (per CLAUDE.md rule).

Metadata

Metadata

Assignees

No one assigned

    Labels

    follow-upDeferred work from PR reviews that needs tracking

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions