Skip to content

[cupertino_ui] Work around dart2wasm optional parameter inference bug in checkbox_test.dart - #12956

Merged
auto-submit[bot] merged 1 commit into
flutter:mainfrom
Piinks:checkbox-wasm-workaround
Sep 21, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:mainfrom
Piinks:checkbox-wasm-workaround

Conversation

@Piinks

@Piinks Piinks commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Adds a workaround in packages/cupertino_ui/test/checkbox_test.dart for a dart2wasm regression introduced in dart-lang/sdk@6eb8d5c ([dart2wasm] Use inferred type also for optional parameters) to unblock the Flutter-to-packages roller (#12904).

Background

When running the full cupertino_ui test suite on WebAssembly, other tests in the bundle keep _RoundedSuperellipseToCircleBorder.copyWith and _RoundedRectangleToCircleBorder.copyWith alive in the OutlinedBorder.copyWith dispatch table selector. Because all call sites targeting those two implementations pass non-null doubles for their optional circularity and eccentricity parameters, Type Flow Analysis (TFA) infers non-nullable double (unboxed f64) for those parameter slots in the shared selector signature (which is also used by RoundedRectangleBorder.copyWith). When _CheckboxPainter._drawBox calls shape.copyWith(side: side) on RoundedRectangleBorder, dart2wasm pushes the selector's default value (NullConstant) into the unboxed f64 parameter slot, causing ConstantInstantiator to emit an unconditional WebAssembly unreachable instruction and hanging the test suite.

Fix

Calling copyWith() without arguments on lerped OutlinedBorder instances in checkbox_test.dart forces TFA to flow Null into the circularity and eccentricity parameter slots of the OutlinedBorder.copyWith selector. This causes dart2wasm to keep those parameters boxed and nullable instead of emitting unreachable in _CheckboxPainter._drawBox, while keeping all checkbox tests enabled.

Workaround for flutter/flutter#193021
Workaround for dart-lang/sdk#64326

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

@Piinks Piinks added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Sep 21, 2026
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Sep 21, 2026
@github-actions github-actions Bot added p: cupertino_ui triage-design Should be looked at in design triage labels Sep 21, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request adds a workaround in packages/cupertino_ui/test/checkbox_test.dart to address a Dart SDK issue where dart2wasm miscompiles shape.copyWith. The review feedback suggests using OutlinedBorder.lerp instead of ShapeBorder.lerp to avoid explicit downcasting, which improves type safety and code clarity.

Comment on lines +25 to +29
(ShapeBorder.lerp(const RoundedRectangleBorder(), const CircleBorder(), 0.5)! as OutlinedBorder)
.copyWith();
(ShapeBorder.lerp(const RoundedSuperellipseBorder(), const CircleBorder(), 0.5)!
as OutlinedBorder)
.copyWith();

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.

medium

Using OutlinedBorder.lerp instead of ShapeBorder.lerp allows you to avoid the explicit downcast (as OutlinedBorder), making the code cleaner and more type-safe.

  OutlinedBorder.lerp(
    const RoundedRectangleBorder(),
    const CircleBorder(),
    0.5,
  )!.copyWith();
  OutlinedBorder.lerp(
    const RoundedSuperellipseBorder(),
    const CircleBorder(),
    0.5,
  )!.copyWith();

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 21, 2026
@auto-submit
auto-submit Bot merged commit 7e3db3b into flutter:main Sep 21, 2026
12 checks passed
auto-submit Bot pushed a commit that referenced this pull request Sep 21, 2026
… in example checkbox tests (#12961)

Follow-up to #12956 to unblock the Flutter-to-packages roller (#12904).

#12956 resolved the dart2wasm hang in packages/cupertino_ui/test/. Previously, CI never reached packages/cupertino_ui/example because the shard timed out while running packages/cupertino_ui.

Now that packages/cupertino_ui passes, CI runs a separate flutter test --platform=chrome --wasm invocation for packages/cupertino_ui/example. Because the example suite compiles into its own standalone Wasm bundle that includes both CupertinoSheet (RoundedSuperellipseBorder) and CupertinoCheckbox, it hits the same dart2wasm optional parameter inference bug in _CheckboxPainter._drawBox when running test/checkbox/cupertino_checkbox.snippet.0_test.dart.

Adds the same OutlinedBorder.copyWith() workaround to cupertino_checkbox.snippet.0_test.dart and cupertino_checkbox.0_test.dart so the example Wasm bundle also keeps the circularity and eccentricity selector parameters nullable.

Workaround for flutter/flutter#193021
Workaround for dart-lang/sdk#64326

## Pre-Review Checklist

**Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

[^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
pull Bot pushed a commit to edisplay/flutter that referenced this pull request Sep 24, 2026
…er#193289)

Roll Packages from c2b58e1a97fb to 431ea69a42e2 (56 revisions)

flutter/packages@c2b58e1...431ea69

2026-09-24 [email protected] [cross_file]
Updates cross_file to a package separated federated plugin
(flutter/packages#11010)
2026-09-23 [email protected] [material_ui]
Remove static access of `copyWith` from `dart fix` golden tests for
`ThemeData/TextTheme` (flutter/packages#12994)
2026-09-23 [email protected] [camera_avfoundation] Replace
deprecated high-resolution capture APIs (flutter/packages#12372)
2026-09-23 [email protected] [pigeon] update nullish checks to use
new isNullish method (flutter/packages#12985)
2026-09-23 [email protected] [ci] Assign batch release PR approver
as reviewer on sync-back PR (flutter/packages#12976)
2026-09-23 [email protected] [image_picker] Fix scaling 10-bit images
(flutter/packages#12557)
2026-09-23 [email protected] [material_ui] Improve
Autocomplete, DrawerHeader, and Tooltip accessibility
(flutter/packages#12918)
2026-09-23 [email protected] [google_fonts] Decouple GoogleFontsLite
for full tree-shaking and add full feature parity
(flutter/packages#12830)
2026-09-23 [email protected] [file_selector]
Ignore flakey `file_selector_android` tests (flutter/packages#12992)
2026-09-23 [email protected] [CI] Remove
bringup from `Mac_arm64 build_all_packages` targets
(flutter/packages#12978)
2026-09-22 [email protected] [material_ui]
Unskip 5 passing web tests in bottom_app_bar_test and text_field_test
(flutter/packages#12983)
2026-09-22 [email protected]
[cupertino_ui] Unskip 5 passing web tests in
adaptive_text_selection_toolbar_test and text_field_test
(flutter/packages#12984)
2026-09-22 [email protected] [go_router] Fix ShellRoute chrome dropped
from semantics tree by ModalBarrier (flutter/packages#12353)
2026-09-22 [email protected] [material_ui]
Add contrastLevel for M3 ColorScheme (flutter/packages#12743)
2026-09-22 [email protected] [go_router] Preserve nested pushes
during config updates (flutter/packages#12611)
2026-09-22 [email protected] [material_ui]
Migrate M3 Chip template to use new gen_defaults
(flutter/packages#12847)
2026-09-22 [email protected] [material_ui] Fix
LocalHistoryEntry leak when double tapping Drawer scrim
(flutter/packages#12552)
2026-09-22 [email protected] Update suggested reviewers
(flutter/packages#12974)
2026-09-22 [email protected] Sync release-material_ui-1.4.0 to
main (flutter/packages#12966)
2026-09-22 [email protected] Sync release-cupertino_ui-1.1.1 to
main (flutter/packages#12965)
2026-09-21 [email protected] [ci] Update repo
for 3.47 stable release (flutter/packages#12959)
2026-09-21 [email protected] Manual roll Flutter from
27fec0e to 4fcd90b (1 revision) (flutter/packages#12904)
2026-09-21 [email protected] Revert "[go_router_builder] Migrate to
material_ui" (flutter/packages#12962)
2026-09-21 [email protected]
[material_ui] Update `material_ui` tests to prevent them from failing
when framework `TextStyle` changes (flutter/packages#12728)
2026-09-21 [email protected] [go_router_builder] Migrate to
material_ui (flutter/packages#12913)
2026-09-21 [email protected] [material_ui,
cupertino_ui] Bump Flutter version from to 3.47 (flutter/packages#12944)
2026-09-21 [email protected] [cupertino_ui] Work around dart2wasm
optional parameter inference bug in example checkbox tests
(flutter/packages#12961)
2026-09-21 [email protected] [cupertino_ui] Work around dart2wasm
optional parameter inference bug in checkbox_test.dart
(flutter/packages#12956)
2026-09-21 [email protected] [google_sign_in] PR 3/4 Migrate
ViewProvider and GID SDK wrappers from Objective-C to Swift
(flutter/packages#12657)
2026-09-21 [email protected] [google_sign_in] PR 2/4 Migrate
the plugin class from Objective-C to Swift. (flutter/packages#12655)
2026-09-20 [email protected]
[cross_file_darwin] iOS/macOS implementation of `cross_file`
(flutter/packages#12910)
2026-09-20 [email protected]
[cross_file_web] Web implementation of `cross_file`
(flutter/packages#12908)
2026-09-20 [email protected] [material_ui]
Migrate M3 `InputChip` template to use new gen_defaults
(flutter/packages#12850)
2026-09-20 [email protected] [material_ui]
Migrate M3 Checkbox defaults to new gen_defaults
(flutter/packages#12816)
2026-09-20 [email protected] [material_ui]
Migrate M3 `FilterChip` template to use new gen_defaults
(flutter/packages#12849)
2026-09-19 [email protected] [material_ui] Announce PopupMenuButton with a
child as a button (flutter/packages#12585)
2026-09-19 [email protected] Roll Flutter (stable) from
9584c67 to 6a19cca (7 revisions) (flutter/packages#12950)
2026-09-18 [email protected] [material_ui]
Reduce the `material_ui` non-wasm web test suite
(flutter/packages#12763)
2026-09-18 [email protected] Replace
`Mac_x64` builders with `Mac_arm64` ones (flutter/packages#12941)
2026-09-18 [email protected]
[in_app_purchase_storekit] Use `_$SKPaymentDiscountWrapperToJson`
(flutter/packages#12721)
2026-09-18 [email protected] [In_app _purchase] README
excerpt examples and changelog (flutter/packages#12739)
2026-09-18 [email protected] [material_ui] Add alternative
input method for `RangeSlider` in `NavigationMode.directional`
(flutter/packages#12630)
2026-09-18 [email protected]
[cross_file_android] Android implementation of `cross_file`
(flutter/packages#12909)
2026-09-18 [email protected]
[camera_platform_interface] Adds videoOutputPath support to
startVideoRecording (flutter/packages#12667)
2026-09-17 [email protected] [cupertino_ui] Migrate a
snippet in `CupertinoCheckbox`'s API doc to `{@example}` and add unit
tests (flutter/packages#12180)
2026-09-17 [email protected] [material_ui]
Default gen_defaults color helper prefix (flutter/packages#12848)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: cupertino_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants