Skip to content

fix(scala): capture trait declarations as class-like nodes#1792

Open
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/scala-trait-declarations
Open

fix(scala): capture trait declarations as class-like nodes#1792
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/scala-trait-declarations

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Bug

Scala trait declarations produce no node and no heritage edges. A trait that extends/with-mixes other types loses all of that structure.

Root cause

_SCALA_CONFIG.class_types contained only class_definition and object_definition. The tree-sitter-scala grammar parses a trait as a trait_definition node, 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

trait Greeter extends Base with Logging { def greet(): Unit }

Before: no Greeter node, no inherits/mixes_in edges.

Fix

Add trait_definition to _SCALA_CONFIG.class_types. The existing Scala extends_clause handler already splits the first base (inherits) from subsequent with mixins (mixes_in), so once the trait becomes a class-like node the edges are emitted correctly.

After the fix:

  • Greeter --inherits--> Base
  • Greeter --mixes_in--> Logging

Testing

  • Added test_scala_trait_definition_heritage to tests/test_languages.py, mirroring the existing test_scala_splits_inherits_and_mixes_in. Fails before, passes after.
  • tests/test_languages.py: 315 passed, 13 skipped.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant