fix(mix_generator): resolve same-build @MixWidget stylers#995
Merged
Conversation
… @MixableSpec stylers A @MixWidget factory returning a Styler generated by @MixableSpec in the same build failed clean builds with "@MixWidget target must resolve to a Style<S> subtype, but got InvalidType": the generated Styler only exists in the combined .g.dart part, which never exists while generators run. When the written return type names an unresolved Styler whose name is derived from a same-library @MixableSpec class, derive the widget call surface from the @MixableSpec(target:) constructor - the same source SpecStylerGenerator uses to emit the styler's call() - keeping generation single-pass. Unmatched unresolved types keep the original diagnostic; a matching spec without target: gets an actionable error.
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.
Related issue
No issue linked.
Description
On a clean build, an
@MixWidgetfactory returning a styler generated by@MixableSpecresolves asInvalidTypebecause the styler only exists in the combined.g.dartoutput produced after both generators run. This causedMixWidgetGeneratorto reject otherwise valid factories before their generatedcall()method existed.The generator now recovers the explicitly written styler type, matches it to a same-library
@MixableSpec, and derives the widget call surface from that spec'starget:constructor—the same source used bySpecStylerGenerator.Changes
Review Checklist
fvm dart test(343 tests),fvm dart analyze, DCM analysis, formatting, andgit diff --checkpass.Additional Information (optional)
The fallback derives from source instead of reading a later-phase generated asset, keeping generation single-pass.