fix(scala): emit heritage edges for qualified extends/with clauses#1794
Open
Synvoya wants to merge 1 commit into
Open
fix(scala): emit heritage edges for qualified extends/with clauses#1794Synvoya wants to merge 1 commit into
Synvoya wants to merge 1 commit into
Conversation
The Scala extends_clause handler only matched type_identifier and generic_type children. A qualified base such as `pkg.Base` or `a.b.Trait` parses as a stable_type_identifier node, so `class Foo extends pkg.Base with other.Trait1` produced no inherits/mixes_in edges at all. Add a stable_type_identifier branch that reads the tail (type_)identifier segment (the real type name, not the package path), consistent with how qualified bases are handled for C++ and Kotlin. Adds a regression test for a qualified extends + with clause.
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.
Bug
A Scala class that extends a qualified type emits no heritage edges.
class Foo extends pkg.Base with other.Trait1produces neither aninheritsnor amixes_inedge.Root cause
The Scala
extends_clausehandler iterated the clause children matching onlytype_identifierandgeneric_type. A qualified base parses as astable_type_identifier:Neither branch matched, so both bases were skipped.
Minimal repro
Before: no
inherits/mixes_inedges.Fix
Add a
stable_type_identifierbranch that reads the tail(type_)identifiersegment (the real type name, not the package path), consistent with the qualified-base handling for C++ (qualified_identifier) and Kotlin. First base afterextendsstaysinherits; eachwithmixin staysmixes_in.After the fix:
Foo --inherits--> BaseFoo --mixes_in--> Trait1Testing
test_scala_qualified_extends_uses_tail_nametotests/test_languages.py. Fails before, passes after.tests/test_languages.py: 315 passed, 13 skipped — the existing unqualified Scala heritage test still passes.