Skip to content

fix(scala): emit heritage edges for qualified extends/with clauses#1794

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

fix(scala): emit heritage edges for qualified extends/with clauses#1794
Synvoya wants to merge 1 commit into
Graphify-Labs:v8from
Synvoya:fix/scala-qualified-extends

Conversation

@Synvoya

@Synvoya Synvoya commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Bug

A Scala class that extends a qualified type emits no heritage edges. class Foo extends pkg.Base with other.Trait1 produces neither an inherits nor a mixes_in edge.

Root cause

The Scala extends_clause handler iterated the clause children matching only type_identifier and generic_type. A qualified base parses as a stable_type_identifier:

extends_clause
  stable_type_identifier "pkg.Base"    -> identifier "pkg" . type_identifier "Base"
  with
  stable_type_identifier "other.Trait1"

Neither branch matched, so both bases were skipped.

Minimal repro

class Foo extends pkg.Base with other.Trait1

Before: no inherits/mixes_in edges.

Fix

Add a stable_type_identifier branch that reads the tail (type_)identifier segment (the real type name, not the package path), consistent with the qualified-base handling for C++ (qualified_identifier) and Kotlin. First base after extends stays inherits; each with mixin stays mixes_in.

After the fix:

  • Foo --inherits--> Base
  • Foo --mixes_in--> Trait1

Testing

  • Added test_scala_qualified_extends_uses_tail_name to tests/test_languages.py. Fails before, passes after.
  • tests/test_languages.py: 315 passed, 13 skipped — the existing unqualified Scala heritage test still passes.

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.
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