Skip to content

fix(mix_generator): resolve same-build @MixWidget stylers#995

Merged
leoafarias merged 1 commit into
mainfrom
fix/mix-widget-styler-resolution
Jul 23, 2026
Merged

fix(mix_generator): resolve same-build @MixWidget stylers#995
leoafarias merged 1 commit into
mainfrom
fix/mix-widget-styler-resolution

Conversation

@leoafarias

Copy link
Copy Markdown
Member

Related issue

No issue linked.

Description

On a clean build, an @MixWidget factory returning a styler generated by @MixableSpec resolves as InvalidType because the styler only exists in the combined .g.dart output produced after both generators run. This caused MixWidgetGenerator to reject otherwise valid factories before their generated call() 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's target: constructor—the same source used by SpecStylerGenerator.

Changes

  • Share target-constructor parsing and styler-backed parameter exclusions between generators.
  • Preserve existing validation, parameter curation, key forwarding, enum variants, and unmatched-type diagnostics.
  • Add resolving integration tests for function and variable factories plus failure diagnostics.

Review Checklist

  • Testing: fvm dart test (343 tests), fvm dart analyze, DCM analysis, formatting, and git diff --check pass.
  • Breaking Changes: None.
  • Documentation Updates: Not required; this fixes generator behavior within the existing annotation contract.
  • Website Updates: Not required.

Additional Information (optional)

The fallback derives from source instead of reading a later-phase generated asset, keeping generation single-pass.

… @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.
@leoafarias
leoafarias merged commit 548a0d9 into main Jul 23, 2026
4 checks passed
@leoafarias
leoafarias deleted the fix/mix-widget-styler-resolution branch July 23, 2026 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant