Repository navigation
fix(dart): resolve every superclass constraint in a mixin on clause - #4899
ayushcodes10 wants to merge 2 commits into
Conversation
A mixin's on clause may list several comma separated superclass constraints, unlike extends, which Dart only ever gives one target since classes have single inheritance. The header parser read only the single type name right after extends or on and stopped there, so every constraint after the first in an on clause was silently dropped: no node, no inherits edge, and its generic argument never surfaced as a reference either. Factored the generic argument reader into its own helper and added a loop that, only for on, keeps consuming further comma separated entries. Extends still only ever reads one entry, so its behavior is unchanged. The later relation mapping block now walks every entry collected this way instead of a single base class and generics pair.
Covers a mixin on clause naming two superclass constraints, asserting both get an inherits edge and the second one's generic argument still surfaces as a reference, plus a control confirming a single constraint on clause still resolves exactly as before.
|
Thanks for the pull request, @ayushcodes10. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 sampled, not proven).
Formal verification. PR-changed functions: 1/1 verified (0 proven, 1 may-equivalent, 0 distinguished) · 0 not verified.
Graphify review — findings
Fixes Dart mixin extraction so mixin Foo on A, B {} emits an inherits edge for every comma-separated superclass constraint, not just the first. Each constraint's generic arguments are parsed too, so something like State<WidgetState> still surfaces a references edge to WidgetState. extends keeps its single-base behavior, and a single-constraint on resolves as before. Tests cover both the multi-constraint case and a single-constraint control.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 45 functions depend on the 44 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
extract_dart()— 15 callers, 9 callees
Verification — 45 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 45 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
2 of 479 test file(s) selected (0%) via static blast radius.
tests/test_dart.py— impact, changed-testtests/test_extract.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
No difference found (not proven): No behavior difference found in extract\_dart (not a proof).
The verifier ran both versions of extract\_dart on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 1 more finding(s) on lines outside this diff (see the check run).
…for video + extractors The four @ayushcodes10 extractor fixes (#4902 R, #4900 elixir, #4899 dart, #4897 fortran) change per-file AST output and are AST-cached; they share the global 31->32 bump already landed via #4908/#4895. Extend the comment to credit them, and add the 0.9.100 changelog entries for #4842 and the four. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed in v0.9.100, now on PyPI (pip install graphifyy==0.9.100). A Dart mixin on A, B clause resolves every superclass constraint. Thanks for the fix, @ayushcodes10. |
Bug
A Dart mixin's
onclause may list several comma-separated superclass constraints (mixin Selectable on Comparable<T>, State<X> {}), unlikeextends, which only ever has one target since Dart classes have single inheritance. The class-header parser inextract_dartonly ever captured the single type name immediately afterextends/onvia a regex with no comma handling. Forextendsthat's correct; foronit silently dropped every constraint after the first — no node, no edge, and the leftover, State<X>text was neither consumed nor matched by the laterwith/implementschecks, so it just vanished.No existing issue or PR covers this; found via self-audit of
graphify/extractors/dart.py(csharp.pyhad nothing demonstrable after a thorough read). The only open PR touching the same class-header block (#2249, "reduce Dart extraction noise") refactors the mixin/interface cleanup helper but does not touch theextends/oncomma-list parsing itself — no overlap. Three other open PRs (#3651, #2114, and closed #415) are full tree-sitter rewrites that would eventually replace this regex extractor entirely, but none are merged, so this interim fix is still worth landing.Fix
Refactored the
extends/onparsing into a_consume_generic_argshelper plus a loop that, only when the keyword ison, keeps consuming further comma-separated, TypeName<Generics>entries into abase_entrieslist.extendsstill only ever reads one entry, so its behavior is unchanged. The later "map inheritance relation" block now iterates every entry inbase_entriesinstead of a singlebase_class/genericspair, so each constraint gets its owninheritsedge and its generic argument still surfaces as areferencesedge.Tests
Added to
tests/test_dart.py:test_mixin_on_clause_with_multiple_superclass_constraints— regression: asserts both constraints getinheritsedges, and the second one's generic argument still surfaces as areferencesedge.test_mixin_on_clause_with_single_superclass_constraint_is_unaffected— control: a single-constraintonclause still resolves exactly as before.Verification
git show upstream/v8:...swapped into place (restored byte-identical afterward): the regression test fails (only the first constraint got an edge), the control passes both before and after.3 failed, 9115 passed, 82 skipped, 1 xfailed— the 3 failures are the pre-existing flakes intest_erlang_extractor.py,test_r_extractor.py, and the skill backtick test, unrelated to this change.python3 -m tools.skillgen --check:check OK: 134 artifact(s) match committed output and expected/.