Skip to content

fix(go): preserve generic receiver method ownership - #833

Merged
tirth8205 merged 2 commits into
tirth8205:mainfrom
merlincat11:agent/fix-832-go-generic-receivers
Aug 19, 2026
Merged

tirth8205 merged 2 commits into
tirth8205:mainfrom
merlincat11:agent/fix-832-go-generic-receivers

Conversation

@merlincat11

Copy link
Copy Markdown

Summary

Fixes #832.

Go methods declared on generic receiver types were emitted as top-level
functions because the receiver parser did not unwrap generic_type nodes.
The fix unwraps generic and pointer receiver nodes to their base type
identifier, preserving method ownership for both T[P] and *T[P] receivers.

Validation

  • uv run --extra dev pytest -q — 2399 passed, 5 skipped, 2 xpassed
  • uv run --extra dev ruff check code_review_graph/parser.py tests/test_multilang.py
  • Validated against Terraform's internal/addrs/graph.go: all 11
    DirectedGraph[T] methods now have parent_name='DirectedGraph'.

Repository-wide Ruff still reports unrelated pre-existing violations in other
test files.

@github-actions

github-actions Bot commented Aug 8, 2026 •

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 4 changed function(s)/class(es), 0 affected flow(s), 2 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/parser.py::CodeParser code_review_graph/parser.py:2403 yes
0.25 low code_review_graph/parser.py::CodeParser._get_go_receiver_type code_review_graph/parser.py:14696 no
0.05 low tests/test_multilang.py::TestGoParsing tests/test_multilang.py:12 no
0.05 low tests/test_multilang.py::TestGoParsing.test_generic_methods_attached_to_receiver tests/test_multilang.py:85 (test)

Test gaps

  • code_review_graph/parser.py::CodeParser._get_go_receiver_type (code_review_graph/parser.py:14696)
  • tests/test_multilang.py::TestGoParsing (tests/test_multilang.py:12)

Token savings: this graph-backed report used ~204,014 fewer tokens (~100%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@merlincat11
merlincat11 marked this pull request as ready for review August 8, 2026 03:01
@tirth8205

Copy link
Copy Markdown
Owner

Confirmed the new test fails on main and that T[P] and *T[P] receiver methods attach correctly, including multi param and unnamed receivers. Merging. Small follow-up: the unwrap in _get_go_receiver_type can land on a comment node, so func (b * /c/ T) F() loses its parent; filtering comment nodes there would cover it.

@tirth8205
tirth8205 merged commit c7b598b into tirth8205:main Aug 19, 2026
11 checks passed
pull Bot pushed a commit to ttnghia/code-review-graph that referenced this pull request Aug 19, 2026
Keep both test blocks at the shared anchor in tests/test_multilang.py:
the generic-receiver regression from tirth8205#833 and the receiver-call
resolution tests from this branch.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012fHfGDiZedoxjpKzanHri3
pull Bot pushed a commit to bhardwajRahul/code-review-graph that referenced this pull request Sep 17, 2026
Untrack docs/superpowers/ and .serena/, drop the private scratch-file list
from .gitignore, de-duplicate GEMINI.md, point the CI badge at the default
branch, and rename the PR-numbered test modules after the behaviour they pin.

- docs/superpowers/specs/: two dated internal design specs were tracked even
  though .gitignore already lists docs/superpowers/. Untracked with
  git rm -r --cached; the ignore rule now holds. The older 2026-07-17 plan and
  spec files under that directory were already removed from the tree.
- .serena/: 160 lines of untouched vendor boilerplate for one contributor's
  tooling. Added .serena/ next to .codex/ under "Local tool configuration" and
  untracked it, matching how .claude/, .codex/ and .qoder/ are handled.
- GEMINI.md was a byte-identical copy of .github/copilot-instructions.md. It is
  now a short pointer to AGENTS.md and CLAUDE.md. Nothing reads it expecting
  full content: the GEMINI.md references in skills.py and test_skills.py are
  about files written into a target repo, under tmp_path.
- .gitignore: the "One-off docs" section named about a dozen private scratch
  files. Replaced with a single scratch/ entry. None of those lines excluded
  build output, so nothing was kept.
- README.md: the CI badge was pinned to ?branch=main while the default branch
  is staging. Now points at staging.
- tests/: 21 modules named after their originating PR are renamed to the
  behaviour they cover, via git mv, with the PR number moved into the module
  docstring. Overlapping modules are folded: tirth8205#831/tirth8205#845/tirth8205#866 into
  test_js_module_resolution.py, tirth8205#830/tirth8205#833 into test_go_receiver_resolution.py,
  tirth8205#824/tirth8205#862 into test_kotlin_import_comments.py. The one non-JS test in the
  tirth8205#866 module moved to test_affected_flows_limits.py.
- Updated the references: CLAUDE.md's "Regressions by pull request" line, and
  the self-referencing filename in the stale-SDK scan (was test_pr856_edges.py,
  now test_genai_packaging.py). CI workflow files and tests/test_documentation.py
  do not name any of the renamed files.

Collected tests: 3370 before, 3370 after. Full suite passes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

[Bug]: (go) generic receiver lose their type

3 participants