fix(solid_generator): seed bare super.x constructor params syntactically - #109
Merged
Merged
Conversation
…ions - example/lib/main.dart: commit the regenerated output; the const drift predated this branch (source lost the const in dev.1, the committed lib was stale) and every rebuild has been surfacing it. The generated call sites legitimately lack const (the const-call-site rewriter is per-file and cannot see sibling-file lowered classes), so example's analysis_options now suppresses prefer_const_constructors. - integration_tests cross_file_env: relative same-package imports (the generator rejects package: self-imports) and a non-const List initializer (const literals are rejected for collection signals) — the fixture was unregenerable: build_runner deleted its two tracked lib/ outputs on every run, masking the second blocker. lib/ keeps always_use_package_imports off (it mirrors source's relative style; test/ deliberately keeps package: imports). - example/examples analysis_options: accept the Flutter-tooling exclude-block auto-migration so pub get stops churning the files.
Closes #108. An annotation-free pure consumer whose only link to a @SolidState class is a bare super.x parameter carried no type text for the probe gate to seed, so the file passed through verbatim and its cross-file reads stayed silently un-lowered. The seeding walk now resolves bare super formals syntactically: the extends-clause name is located in the current unit or via the import walk (alias/prefix-aware, same-package imports only, local declarations shadow), the targeted super constructor is matched (named or unnamed; positional matching among super formals is unambiguous — Dart rejects the mixes that could confuse it), untyped this.x matches fall back to the superclass field's type, super-formal chains recurse with a depth bound, and generic type parameters map by index to the extends-clause type arguments. Ambiguity over-seeds candidate names instead of guessing. The registry walk gains a one-hop extension into the located superclass file's own imports — gated by the consuming file's local declarations (review caught the ungated version rewriting a local plain class) — since the consumer typically imports only its base file. Syntactic seeding is skipped when resolved-path resolution already succeeded, so ubiquitous {super.key} params never trigger file reads. Five golden fixture families cover the issue shape (de-rigged: the consumer imports only its base file), named targets and named params, two-hop chains, generic bases, the local-shadow decoy, and a no-@SolidState negative proving the fast path survives. Validated against a real downstream app via path overrides before release: byte-identical output on the app itself plus a probe of the exact issue shape lowering correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #108. Cut as
solid_generator 3.0.0-dev.5.Problem
An annotation-free pure consumer whose ONLY link to a
@SolidStateclass is a baresuper.xconstructor parameter carries no type text anywhere in its file — the syntactic probe gate (#107) had nothing to seed, the file passed through verbatim, and its cross-file reads stayed silently un-lowered (samedart fixdead-code hazard as #106, on a rarer shape).Fix (stays syntactic)
super.xresolves via the extends-clause name → located in the current unit or the import walk (alias/prefix-aware; same-package imports only —{super.key}never touches Flutter files; local declarations shadow) → targeted super constructor matched (named/unnamed; positional matching among super formals is provably unambiguous — Dart rejects the confusable mixes) →this.xmatches fall back to the superclass field's type → super-formal chains recurse (depth-bounded) → generic type parameters map by index to the extends-clause type arguments. Ambiguity over-seeds candidate names, never guesses..valueon a local plain class).Review guide — fixtures (
test/golden/)cross_file_super_param_bare_pure_consumersuper.named()targets + named paramcross_file_super_param_bare_chaincross_file_super_param_generic_baseextends Base<AuthRepository>type-argument mappingcross_file_super_param_one_hop_local_shadowcross_file_super_param_bare_no_stateAlso in this PR (separate commit)
Repo hygiene repeatedly surfaced by rebuilds: regenerated
example/lib/main.dart(pre-existing const drift;prefer_const_constructorssuppressed with rationale — the const-call-site rewriter is per-file),integration_tests/cross_file_envmade regenerable (relative imports + non-const list init; two latent blockers), Flutter-toolingexclude:migrations accepted to endpub getchurn.Verification
349/349 solid_generator tests (5 new fixture families + idempotency), 11/11 integration, repo-root
dart analyze --fatal-infoszero (CI's exact gate), format clean, examples zero-delta, RED authenticity re-proven against main. Pre-release validation against the real downstream app (fairtile accountant_app via path overrides): byte-identicallib/on the app itself, plus a planted probe of the exact issue shape lowering tosession.value— tree left clean.Known residuals (documented): a class reachable only through a 2+ hop import chain;
part-file consumers (pre-existing pipeline-wide limit); name-keyed registry collision surface (SPEC §4.9).