Skip to content

fix(generator): support generic @MixWidget call methods#958

Merged
tilucasoli merged 3 commits into
mainfrom
fix/mix-widget-generic-call
Jul 7, 2026
Merged

fix(generator): support generic @MixWidget call methods#958
tilucasoli merged 3 commits into
mainfrom
fix/mix-widget-generic-call

Conversation

@leoafarias

Copy link
Copy Markdown
Collaborator

Summary

  • allow @MixWidget to generate widgets from generic styler call<T>() methods
  • preserve call type parameter bounds on the generated widget class
  • forward generic type arguments when invoking the styler call method

Why

Remix needs generated Fortal widgets for generic radio and accordion APIs, e.g. FortalRadio<T> and FortalAccordion<T>. The published generator rejects generic call() methods today, which blocks reproducible code generation and pushes consumers toward hand-written widget drift.

Fixes #957.

Validation

  • fvm dart pub get
  • fvm dart test from packages/mix_generator passes, 277 tests

@leoafarias leoafarias changed the title [codex] Support generic @MixWidget call methods fix(generator): support generic @MixWidget call methods Jul 6, 2026
@leoafarias leoafarias force-pushed the fix/mix-widget-generic-call branch from 206fd12 to 39e60af Compare July 6, 2026 22:38
Also adds a validation test for call type parameter bounds that aren't
visible from the annotated library, a path that previously had no
coverage.
@leoafarias leoafarias marked this pull request as ready for review July 6, 2026 23:37
@tilucasoli tilucasoli requested a review from Copilot July 6, 2026 23:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates mix_generator’s @MixWidget support to allow generating widgets from generic styler call<T>() methods, preserving type parameter bounds on the generated widget class and forwarding type arguments when invoking the styler call—unblocking generic Remix/Fortal-style APIs like FortalRadio<T>.

Changes:

  • Extend MixWidgetGenerator to accept generic call<T>() methods when the return type is Widget-assignable (including T extends Widget), and validate type-parameter bound visibility.
  • Add callTypeParams plumbing to the model/builder to emit generic widget classes and forward .call<T>() invocations.
  • Add integration + unit test coverage for success cases and key rejection paths (non-widget bounds, hidden bound types, prefixed Flutter imports).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/mix_generator/lib/src/mix_widget_generator.dart Accepts/validates generic call<T>(), extracts type params/bounds, and enforces bound visibility + unprefixed Flutter base symbols.
packages/mix_generator/lib/src/core/models/mix_widget_model.dart Adds WidgetCallTypeParam + model helpers for class generic declarations and call invocations.
packages/mix_generator/lib/src/core/builders/mix_widget_builder.dart Emits generic widget class declarations and forwards type args on .call<...>().
packages/mix_generator/test/integration/generator_smoke_test.dart Adds end-to-end smoke tests asserting generated output for generic widgets and forwarded type args.
packages/mix_generator/test/integration/generator_validation_test.dart Adds validation tests for invalid generic-return shapes and bound visibility/import constraints.
packages/mix_generator/test/core/builders/mix_widget_builder_test.dart Adds unit tests for generic class emission, bound preservation, and type-arg forwarding in the builder.
packages/mix_generator/pubspec.yaml Bumps package version to 2.1.2.
packages/mix_generator/CHANGELOG.md Documents the new fix in 2.1.2.

@tilucasoli tilucasoli merged commit 8622130 into main Jul 7, 2026
5 checks passed
@tilucasoli tilucasoli deleted the fix/mix-widget-generic-call branch July 7, 2026 00: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.

Support @MixWidget for generic styler call<T>() methods

3 participants