Files
graphify/tests
Faisal01011 447d41dd0d fix(extract): keep Scala file-scope val/var type references (#2054)
Scala 3 allows `val`/`var` to be written directly at file scope with no
enclosing object/class/trait. The `val_definition`/`var_definition`
type-reference dispatch was gated on `and parent_class_nid`, so a file-scope
binding produced no node and no edge of any kind, while the byte-identical
definition nested one level inside any container resolved correctly. The
missing container was the only difference: both positions parse to the same
node type carrying the same `type` field.

This is the Scala instance of a generic defect in the walker's default
recursion path that had already caused and been fixed once for Python
(#1050) -- a position that legitimately has no container must fall back to
the file node rather than be skipped. The fix reuses the `owner_nid =
parent_class_nid or file_nid` idiom already present in the property branch
above, and moves the self-reference guard onto the same anchor so a
file-scope binding cannot mint an edge from the file node to itself.

Behaviour is unchanged for class-nested bindings; a regression test pins
that case explicitly.

Verified:
- uv run pytest tests/test_scala_top_level_binding.py -q  (8 passed)
- 6 of the 8 new tests fail on the pre-fix tree, 2 pass either way
  (the in-class control, and the self-edge guard which is trivially empty
  before the fix and meaningful after it)
- uv run pytest tests/ -q -> 28 failed, 6144 passed, 101 skipped; the 28
  failures are byte-identical to the clean-tree baseline (missing
  tree-sitter grammars for erlang/R/solidity/vbnet, plus ollama retry
  tests) and none touch Scala
- uv run ruff check . -> clean
- uv run pyright -> 635 errors, identical to the clean-tree baseline
  (pre-existing debt; this change adds none)

Co-Authored-By: Claude <noreply@anthropic.com>
(cherry picked from commit 2d61ef7e68)
2026-10-04 02:07:00 +01:00
..