Repository navigation
Conversation
An interface type_elem that is a generics type-set constraint - a union
(`A | B`) or an approximation (`~T`) - was walked like an embedded
interface, so each non-predeclared term produced an `embeds` heritage
edge (e.g. `type Number interface { MyInt | MyFloat }` emitted
Number->MyInt and Number->MyFloat embeds).
Go only embeds a lone interface type, and each embed is its own element;
union/approximation terms are a constraint type set that can never be
embedded, so those edges assert composition that does not exist. Detect
type-set elems (a `|` or `negated_type` child) and reclassify their
terms as `references` (context=type_constraint), preserving the type
link without the false heritage edge. Genuine interface embedding
(single/qualified/generic interface terms) is unchanged.
Adds regression coverage: positive guards for struct and interface
embedding, plus a negative control asserting union terms are not embeds.
bc877de to
72ddb3a
Compare
|
Rebased onto current This is the strongest, most self-contained fix in my open extractor batch, so I’d appreciate prioritizing this one. I’ll hold off on additional Graphify PRs while the existing batch is reviewed, and I’m happy to adjust or close lower-priority items if you prefer a narrower queue. |
Ships two batches: the robot/defang/watch/semantic-guard set — Robot Framework extractor (#3192), generalized control-token defang (#3183), watch unresolved-link preservation (#3190), unverified-semantic-loss guard (#3203), hook-guard search detection (#3121), stale-SKILL.md backup (#3144), report/wiki count fixes (#3148/#3127); and a rescued batch of @Synvoya cross-language inheritance-edge corrections (JS #1790, PHP #1791, Scala #1792/#1794, Kotlin #1793, C# #1817, Go #1818) that had been buried in the backlog for ~7 weeks. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Shipped in v0.9.53 via authorship-preserving cherry-pick so you keep contributor-graph credit. Thanks @Synvoya — this was verified still-live on the current tree and landed as part of a cross-language heritage-edge batch. Release: https://github.com/Graphify-Labs/graphify/releases/tag/v0.9.53 |
Problem
The Go extractor treats every interface
type_elemas an embedded interface.But a Go type-set constraint (generics) is not embedding — a union
A | Bor an approximation~Tis a set of type terms, and Go only everembeds a lone interface type. Because the branch walked union terms the same
way it walks an embedded interface, each non-predeclared term produced a
spurious
embedsheritage edge.Reproduction on
v8HEADextract_goemits:embedsis a heritage relation (grouped withinherits/implements/mixes_ininextract.py), so this asserts a composition/method-promotionrelationship that does not exist —
Numbercannot embed the concrete typesMyInt/MyFloat; they are constraint terms. This pollutes heritage queriesover the graph with false edges.
Fix
Detect a type-set
type_elem(it has a|or anegated_typechild — bothtokens appear only in constraint position, never in embedding) and reclassify
its terms as
references(context="type_constraint") instead ofembeds.This keeps the type link but drops the false heritage claim. The edge count is
unchanged; only the relation/context is corrected.
Genuine interface embedding is untouched — a lone interface term
(
Reader,io.Reader,Sortable[int]) has no|/~, so it still emitsembeds.Tests
Added to
tests/test_languages.py:test_go_interface_type_union_is_not_embedding— negative control:union terms must not be
embeds, and are present asreferences/type_constraint. Fails on HEAD (asserts the spuriousNumber->MyIntembed away), passes with the fix.test_go_interface_embedding_emits_embeds/test_go_struct_embedding_emits_embeds— positive guards that genuineembedding on the existing
sample.gofixture (ReaderLoggerembedsLogger/Reader;DataProcessorembedsBaseProcessor) still works.python3 -m pytest tests/test_languages.py -q→317 passed, 13 skipped(the 13 skips are the optional
tree-sitter-dmgrammar). No behavior changeoutside Go interface type-set constraints.