@@ -745,6 +745,35 @@ def test_scala_splits_inherits_and_mixes_in():
745745 assert ("HttpClient" , "Loggable" ) in _edge_labels (r , "mixes_in" )
746746
747747
748+ def test_scala_qualified_extends_uses_tail_name (tmp_path ):
749+ """A qualified base like `pkg.Base` is a `stable_type_identifier` node in the
750+ extends_clause. The handler only matched `type_identifier`/`generic_type`, so
751+ qualified extends/with clauses were dropped. Resolve them to the tail type
752+ name (`Base`, `Trait1`), not the package path.
753+ """
754+ f = tmp_path / "foo.scala"
755+ f .write_text (
756+ "class Foo extends pkg.Base with other.Trait1\n "
757+ "class Generic extends pkg.Base[Int] with other.Trait1[String]\n "
758+ "class Constructed extends outer.pkg.Base[Int](42) "
759+ "with a.b.Trait1[String]\n "
760+ )
761+ r = extract_scala (f )
762+ inherits = _edge_labels (r , "inherits" )
763+ mixes_in = _edge_labels (r , "mixes_in" )
764+ assert ("Foo" , "Base" ) in inherits
765+ assert ("Foo" , "Trait1" ) in mixes_in
766+ assert ("Generic" , "Base" ) in inherits
767+ assert ("Generic" , "Trait1" ) in mixes_in
768+ assert ("Constructed" , "Base" ) in inherits
769+ assert ("Constructed" , "Trait1" ) in mixes_in
770+ # Package qualifiers and generic arguments are not parent type names.
771+ assert ("Generic" , "pkg.Base" ) not in inherits
772+ assert ("Generic" , "other.Trait1" ) not in mixes_in
773+ assert ("Constructed" , "Int" ) not in inherits
774+ assert ("Constructed" , "String" ) not in mixes_in
775+
776+
748777def test_scala_constructor_parameter_field_context ():
749778 r = extract_scala (FIXTURES / "sample.scala" )
750779 assert ("HttpClient" , "Config" ) in _edge_labels (r , "references" , "field" )
0 commit comments