fix(solid_generator): cross-instance @SolidState in mixed-file pure consumers (dev.10) - #116
Merged
Merged
Conversation
…pure consumers Whole-file pure-consumer lowering only ran when NO class in the file was annotated. In a mixed file, a no-annotation consumer that reaches another class's @SolidState through a plain constructor/instance field was passed through verbatim, so a cross-instance write (vm.x = v) hit assignment_to_final on the generated final Signal, and reads stayed non-reactive. Adds a per-class lowerPureConsumerClass (mirroring the whole-file collectors) that _resultForClass invokes for no-annotation classes, so the same .value lowering + SignalBuilder wrap fires in mixed files too. Adds mixed_file_pure_consumer_{widget,plain_class} goldens. Reviewed by 2 adversarial reviewers (0 findings; plain-class golden added on rec).
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.
Problem
Whole-file pure-consumer lowering (
lowerPureConsumers) only runs when every class in a file is annotation-free. In a mixed file — a no-annotation presentation widget/class co-located with the annotated class it consumes —_resultForClasspassed the consumer through verbatim. So a cross-instance@SolidStatewrite through a plain constructor/instance field:stayed un-lowered →
counter.count = …hitassignment_to_finalon the generatedfinal Signal, and the read stayed non-reactive (noSignalBuilder).Fix
New per-class
lowerPureConsumerClass(mirrors the two whole-file collectors:build→rewriteBuildMethodfor.value+ wrap; other ctors/methods →collectValueEdits; applied viaapplyEditsToRange(slice, edits, decl.offset))._resultForClasscalls it forhasNoAnnotationsclasses instead of a verbatim passthrough, returning{'SignalBuilder'}on wrap soflutter_solidartis imported. The pure consumer is not lifted and gains noDisposable— it owns no reactive member.Tests
mixed_file_pure_consumer_widget(StatelessWidget: write+read lowered, wrapped, imported) andmixed_file_pure_consumer_plain_class(plain class: read+write lowered, no wrap, no Disposable).dart analyze libclean.Reviewed by 2 adversarial reviewers (0 findings). Bumps
solid_generatorto 3.0.0-dev.10.