mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-09-16 23:43:12 +00:00
Review feedback from PR #980 reviewer flagged a BLOCKING correctness bug: when two classes in the same file define a method with the same simple name (e.g. class User: def save + class Document: def save), every d.save() CALLS edge silently resolved to User.save because the graph node lookup keyed only by (filePath, simpleName) and first-wins took User's method. Three-layer fix: 1. populateClassOwnedMembers now promotes a nested def's qualifiedName from `save` to `ClassName.save` when the def sits inside a class scope. Python's scopes.scm doesn't emit @declaration.qualified_name for methods, so without this the finalized SymbolDefinition carried only the simple name. 2. buildGraphNodeLookup adds a second key per node: (filePath, qualifiedName). For Method/Function nodes the qualifier is parsed deterministically out of the node id (`Method:file.py:User.save#N` → `User.save`), which is robust to Windows-style filePath colons. Simple-name key retained as a fallback for callers that don't know the qualifier. 3. resolveDefGraphId now tries the qualified key first, then falls back to the simple-name lookup. Also addresses the non-blocking review items: - scopeResolutionPhase.deps now includes `crossFile` so the Kahn's runner can't schedule scope-resolution before crossFile finishes writing heritage edges that buildMro consumes. - run.ts no longer mutates the finalized ScopeResolutionIndexes via `as` cast — spreads into a fresh object with the populated methodDispatch field instead. - Doc nits: scope-resolver.ts registry path + phase.ts Ring number. Test coverage: - New fixture test/fixtures/lang-resolution/python-same-file-method-collision with User.save + Document.save in one file and app.py calling both through typed receivers. - Three new integration assertions pin that u.save() and d.save() target the correct qualified node id. Fail before the fix, pass after. Confirmed by running once without populateClassOwnedMembers qualifier promotion — reproduces the original User.save-for-both bug. Verification: 194/194 test/integration/resolvers/python.test.ts pass both REGISTRY_PRIMARY_PYTHON=0 and =1. 523/523 related unit tests. tsc --noEmit clean.
22 lines
509 B
Python
22 lines
509 B
Python
"""
|
|
Two classes in one file each defining a method with the same simple
|
|
name. Exercises the node-lookup qualified-name key — without it,
|
|
both User.save and Document.save share the bucket `models.py::save`
|
|
and every `document.save()` CALLS edge silently resolves to User.save.
|
|
"""
|
|
|
|
|
|
class User:
|
|
def save(self) -> bool:
|
|
return True
|
|
|
|
def load(self) -> None:
|
|
return None
|
|
|
|
|
|
class Document:
|
|
def save(self) -> bool:
|
|
return False
|
|
|
|
def load(self) -> None:
|
|
return None
|