fix(scala): capture trait declarations as class-like nodes#1792
Open
Synvoya wants to merge 1 commit into
Open
Conversation
trait_definition was missing from _SCALA_CONFIG.class_types, so Scala traits produced no node and their heritage (`extends Base with Logging`) was dropped. Add trait_definition to the Scala class_types; the existing extends_clause handler then emits the inherits/mixes_in edges. Adds a regression test for a trait with an 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
Scala
traitdeclarations produce no node and no heritage edges. Atraitthatextends/with-mixes other types loses all of that structure.Root cause
_SCALA_CONFIG.class_typescontained onlyclass_definitionandobject_definition. The tree-sitter-scala grammar parses a trait as atrait_definitionnode, which was therefore never treated as class-like — so it never became a node and the Scala heritage handler never ran for it.Minimal repro
Before: no
Greeternode, noinherits/mixes_inedges.Fix
Add
trait_definitionto_SCALA_CONFIG.class_types. The existing Scalaextends_clausehandler already splits the first base (inherits) from subsequentwithmixins (mixes_in), so once the trait becomes a class-like node the edges are emitted correctly.After the fix:
Greeter --inherits--> BaseGreeter --mixes_in--> LoggingTesting
test_scala_trait_definition_heritagetotests/test_languages.py, mirroring the existingtest_scala_splits_inherits_and_mixes_in. Fails before, passes after.tests/test_languages.py: 315 passed, 13 skipped.