Repository navigation
fix(extract): drop Scala generic type parameters from references - #4407
Closed
rajatnagda45 wants to merge 1 commit into
Closed
rajatnagda45 wants to merge 1 commit into
rajatnagda45 wants to merge 1 commit into
Conversation
A `class Box[T]` / `def map[R](...)` binds `T`/`R` as local names, not corpus symbols, but `_scala_collect_type_refs` appended the bare identifiers used in a signature as type references and ran them through the sourceless-stub path. Every generic class/method in the corpus then collapsed its `T` onto one bare `t` node — a god node that pollutes god-node rankings, since single-letter type parameters are not in the analyzer's builtin-noise filter. C#, Java, TypeScript, Kotlin, and Go already exclude theirs. Mirrors that pattern: a new `_scala_type_parameters_in_scope` helper walks up to every enclosing declaration's `type_parameters` list (the use site is `type_arguments`, a distinct node) and collects parameter names from direct identifiers and variance-annotated params, skipping `context_bound`/ `upper_bound`/`lower_bound` nodes (those name real types). `_scala_collect_type_refs` auto-computes and threads that skip set. Context bounds (Graphify-Labs#2046), genuine user types, and the generic container head still reference.
|
Thanks for the pull request, @rajatnagda45. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
safishamsi
added a commit
that referenced
this pull request
Oct 13, 2026
Kotlin/Scala/C++/Swift generic & template type-param pruning (#4406, #4407, #4408, #4409), Objective-C NS_ENUM/NS_OPTIONS extraction and callable markers (#4401, #3385), and Go/PHP receiver-typed member-call parking (#3395, #3391) all change AST extraction output, so warm caches must re-extract. Co-Authored-By: Claude Opus 4.8 <[email protected]>
Member
|
Shipped in v0.9.89, just released to PyPI as |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4403.
Problem
_scala_collect_type_refsappends the bareT/Ridentifiers used in a generic signature as type references and runs them through the sourceless-stub path. Every generic class/method then collapses itsTonto one baretnode — a god node that pollutes god-node rankings (single-letter type params are not in the analyzer's builtin-noise filter). C#, Java, TypeScript, Kotlin, and Go already exclude theirs.Implementation
A new
_scala_type_parameters_in_scopehelper walks up to every enclosing declaration'stype_parameterslist and collects parameter names from direct identifiers and variance-annotated params ([+A]/[-B]), skippingcontext_bound/upper_bound/lower_boundnodes (those name real types)._scala_collect_type_refsauto-computes and threads that skip set. Context bounds (#2046), genuine user types, and the generic container head still reference.Verification
New
tests/test_scala_generic_type_params.py(generic class+method; a bounds/variance guard asserting the context bound and real types survive). The generic-signature case fails on pre-fix v8 and passes with the fix; existingtests/test_scala_context_bounds.pystays green.Commands run:
uv run pytest tests/(7691 passed, 15 skipped; security/wheel excluded)uv run ruff check .(clean)uv run pyright graphify/extractors/engine.py(34 errors, 0 added vs v8)Limitations
An upper bound (
[T <: Base]) is deliberately not emitted as a reference (existing behavior, #2046); onlycontext_bounddependencies are kept.