Skip to content

fix(cpp): workspace-wide dependent-base name resolution for cross-file templates#1586

Merged
magyargergo merged 4 commits into
mainfrom
copilot/fix-cpp-dependent-base-resolution
May 14, 2026
Merged

fix(cpp): workspace-wide dependent-base name resolution for cross-file templates#1586
magyargergo merged 4 commits into
mainfrom
copilot/fix-cpp-dependent-base-resolution

Conversation

Copilot AI commented May 14, 2026

Copy link
Copy Markdown
Contributor

populateCppDependentBases resolved base-class simple names against the same file's localDefs only. When Base<T> lives in base.h and Derived<T> in derived.h, the dependent-base nodeId set was always empty — isCppDependentBaseMember could never suppress. The existing test passed accidentally because the class-owned isFileLocalDef filter blocked the same candidates first.

Changes

  • cpp/two-phase-lookup.tspopulateCppDependentBases(parsed: ParsedFile)populateCppDependentBases(parsedFiles: readonly ParsedFile[]). Builds a workspace-wide simpleName → {nodeId, nsPrefix}[] index across all files. Namespace disambiguation uses the qualified-name prefix (ns.ClassName → prefix ns): prefers same-namespace candidates when names collide, accepts unique matches, conservatively skips ambiguous cases (V1; cross-namespace and inline-namespace deferred).

  • cpp/scope-resolver.ts — Removes the call from populateOwners (per-file); adds a populateWorkspaceOwners hook so resolution runs after every file has been processed and all class defs are reachable.

  • New fixture cpp-two-phase-dependent-base-ns/geom::Base<T> in base.h with a class method compute() and a namespace-free function compute() (no ownerId; class-owned filter does not apply to it). geom::Derived<T> in derived.h calls compute() unqualified. Two new integration assertions confirm zero leaked edges in this variant, verifying the suppression stack independently of the class-owned filter.

@vercel

vercel Bot commented May 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
gitnexus Ready Ready Preview, Comment May 14, 2026 11:34am

Request Review

…upport)

- Replace per-file `populateCppDependentBases(parsed)` with a workspace-wide
  `populateCppDependentBases(parsedFiles)` that builds a cross-file class index
- Use qualified-name prefix for namespace disambiguation when multiple classes
  share a simple name (e.g. `Box` in two namespaces)
- Move the call from `populateOwners` (per-file) to the new `populateWorkspaceOwners`
  hook so all files are processed before resolution runs
- Add `cpp-two-phase-dependent-base-ns` fixture: Base<T> in a namespace in a
  separate file from Derived<T>, plus a namespace-free function with the same
  name — exercises the path where the class-owned filter does not apply
- Add two integration tests for the new fixture"

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/d78fae8b-cd32-45d8-a815-2b27d7d89e62

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
…-phase-lookup

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/d78fae8b-cd32-45d8-a815-2b27d7d89e62

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix cross-file dependent-base name resolution in C++ fix(cpp): workspace-wide dependent-base name resolution for cross-file templates May 14, 2026
Copilot AI requested a review from magyargergo May 14, 2026 11:34
@magyargergo magyargergo marked this pull request as ready for review May 14, 2026 11:58
@github-actions

Copy link
Copy Markdown
Contributor

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@magyargergo magyargergo merged commit c901ee4 into main May 14, 2026
37 of 40 checks passed
@magyargergo magyargergo deleted the copilot/fix-cpp-dependent-base-resolution branch May 14, 2026 12:06
hohaivu pushed a commit to hohaivu/GitNexus that referenced this pull request May 19, 2026
…e templates (abhigyanpatwari#1586)

* Initial plan

* fix(cpp): workspace-wide dependent-base name resolution (cross-file support)

- Replace per-file `populateCppDependentBases(parsed)` with a workspace-wide
  `populateCppDependentBases(parsedFiles)` that builds a cross-file class index
- Use qualified-name prefix for namespace disambiguation when multiple classes
  share a simple name (e.g. `Box` in two namespaces)
- Move the call from `populateOwners` (per-file) to the new `populateWorkspaceOwners`
  hook so all files are processed before resolution runs
- Add `cpp-two-phase-dependent-base-ns` fixture: Base<T> in a namespace in a
  separate file from Derived<T>, plus a namespace-free function with the same
  name — exercises the path where the class-owned filter does not apply
- Add two integration tests for the new fixture"

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/d78fae8b-cd32-45d8-a815-2b27d7d89e62

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

* fix(cpp): clarify V1 conservative exact-prefix namespace match in two-phase-lookup

Agent-Logs-Url: https://github.com/abhigyanpatwari/GitNexus/sessions/d78fae8b-cd32-45d8-a815-2b27d7d89e62

Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
Co-authored-by: magyargergo <11230420+magyargergo@users.noreply.github.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.

cpp: cross-file dependent-base name resolution

2 participants