Skip to content

Revert: Split the platform and cpuArch part of TargetPlatform - #190258

Merged
auto-submit[bot] merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-189479-1785369766
Jul 30, 2026
Merged

auto-submit[bot] merged 1 commit into
flutter:masterfrom
flutteractionsbot:revert-189479-1785369766

Conversation

@flutteractionsbot

@flutteractionsbot flutteractionsbot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Reverts: Split the platform and cpuArch part of TargetPlatform

Initiated by: @chingjun

Reason for reverting: Broke postsubmit test. See #190252

Original PR Author: @chingjun

Reviewed By: @bkonyi

The original PR description is provided below:

Convert enum TargetPlatform into a class with two fields: TargetPlatformType and CpuArch.

Fixes: #190252

@flutteractionsbot
flutteractionsbot requested review from a team as code owners July 30, 2026 00:02
@flutteractionsbot
flutteractionsbot requested review from mboetger and removed request for a team July 30, 2026 00:02
@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Jul 30, 2026
@github-actions github-actions Bot added platform-ios iOS applications specifically tool Affects the "flutter" command-line tool. See also t: labels. platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically platform-linux Building on or for Linux specifically a: desktop Running on desktop team-android Owned by Android platform team team-ios Owned by iOS platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team team-linux Owned by the Linux platform team labels Jul 30, 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 refactors TargetPlatform from a class combining platform type and CPU architecture into a single enum, updating platform checks across flutter_tools to use direct enum comparisons. Feedback from the review highlights opportunities to improve code safety and readability. This includes adding an assertion in AOTSnapshotter to prevent a potential null dereference when targeting macOS, refactoring several switch statements into modern Dart switch expressions with wildcard patterns, and replacing unnecessarily complex pattern matching case statements with standard equality checks.

required bool dartObfuscation,
bool quiet = false,
}) async {
assert(platform != TargetPlatform.ios || cpuArch != null);

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.

high

Since cpuArch is unconditionally dereferenced on line 175 (cpuArch!.darwinArchName) when platform == TargetPlatform.darwin, we should also assert that cpuArch is not null for TargetPlatform.darwin to prevent a potential runtime crash.

Suggested change
assert(platform != TargetPlatform.ios || cpuArch != null);
assert((platform != TargetPlatform.ios && platform != TargetPlatform.darwin) || cpuArch != null);

Comment on lines +207 to +229
TargetPlatform? _mapTargetPlatform(TargetPlatform? targetPlatform) {
switch (targetPlatform) {
case TargetPlatform.android:
return TargetPlatform.android_arm64;
case TargetPlatform.ios:
case TargetPlatform.darwin:
case TargetPlatform.linux_x64:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_riscv64:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.unsupported:
case null:
return targetPlatform;
}
}

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

This switch statement can be significantly simplified and made more maintainable by using a switch expression with a wildcard pattern (_). This avoids having to list every single enum value and manually return targetPlatform for each of them.

TargetPlatform? _mapTargetPlatform(TargetPlatform? targetPlatform) {
  return switch (targetPlatform) {
    TargetPlatform.android => TargetPlatform.android_arm64,
    _ => targetPlatform,
  };
}
References
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

Comment on lines +230 to +249
switch (await targetPlatform) {
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
return buildMode != BuildMode.jitRelease;
case TargetPlatform.android:
case TargetPlatform.darwin:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_riscv64:
case TargetPlatform.linux_x64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.unsupported:
throw UnsupportedError('Invalid target platform for Android');
}

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

This switch statement can be simplified and made more robust by using a switch expression with a wildcard pattern (_). This avoids listing all non-Android platforms and makes the code much easier to maintain if new platforms are added to TargetPlatform in the future.

    final TargetPlatform platform = await targetPlatform;
    return switch (platform) {
      TargetPlatform.android_arm ||
      TargetPlatform.android_arm64 ||
      TargetPlatform.android_x64 => buildMode != BuildMode.jitRelease,
      _ => throw UnsupportedError('Invalid target platform for Android: $platform'),
    };
References
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)


// Configure the compiler to target the DDC runtime.
if (targetPlatform.type == .web) {
if (targetPlatform case .web_javascript) {

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 pattern matching case for a simple equality check on a non-nullable enum is unnecessarily complex. A standard == comparison is more readable and idiomatic.

Suggested change
if (targetPlatform case .web_javascript) {
if (targetPlatform == TargetPlatform.web_javascript) {

);
} else {
if (targetPlatform.type == .fuchsia) {
if (targetPlatform case .fuchsia_arm64 || .fuchsia_x64) {

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 pattern matching case with logical OR inside an if statement is less readable than standard equality checks. A standard == comparison with || is more idiomatic.

Suggested change
if (targetPlatform case .fuchsia_arm64 || .fuchsia_x64) {
if (targetPlatform == TargetPlatform.fuchsia_arm64 ||
targetPlatform == TargetPlatform.fuchsia_x64) {

Comment on lines +239 to +260
final bool forceLinkPlatform;
switch (targetPlatform) {
case TargetPlatform.darwin:
case TargetPlatform.windows_x64:
case TargetPlatform.windows_arm64:
case TargetPlatform.linux_x64:
forceLinkPlatform = true;
case TargetPlatform.android:
case TargetPlatform.android_arm:
case TargetPlatform.android_arm64:
case TargetPlatform.android_x64:
case TargetPlatform.fuchsia_arm64:
case TargetPlatform.fuchsia_x64:
case TargetPlatform.ios:
case TargetPlatform.linux_arm64:
case TargetPlatform.linux_riscv64:
case TargetPlatform.tester:
case TargetPlatform.web_javascript:
forceLinkPlatform = false;
case TargetPlatform.unsupported:
TargetPlatform.throwUnsupportedTarget();
}

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

This switch statement can be refactored into a switch expression, which is cleaner, more concise, and more idiomatic in modern Dart. It also avoids declaring a local variable without initializing it.

    final bool forceLinkPlatform = switch (targetPlatform) {
      TargetPlatform.darwin ||
      TargetPlatform.windows_x64 ||
      TargetPlatform.windows_arm64 ||
      TargetPlatform.linux_x64 => true,
      TargetPlatform.android ||
      TargetPlatform.android_arm ||
      TargetPlatform.android_arm64 ||
      TargetPlatform.android_x64 ||
      TargetPlatform.fuchsia_arm64 ||
      TargetPlatform.fuchsia_x64 ||
      TargetPlatform.ios ||
      TargetPlatform.linux_arm64 ||
      TargetPlatform.linux_riscv64 ||
      TargetPlatform.tester ||
      TargetPlatform.web_javascript => false,
      TargetPlatform.unsupported => TargetPlatform.throwUnsupportedTarget(),
    };
References
  1. Suggest simplification and refactoring: Assess whether the code can be made simpler or refactored to enhance readability and maintainability. (link)

@chingjun chingjun added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 30, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Jul 30, 2026
Merged via the queue into flutter:master with commit ddb43a3 Jul 30, 2026
28 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jul 30, 2026
@flutteractionsbot
flutteractionsbot deleted the revert-189479-1785369766 branch July 30, 2026 06:23
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Aug 9, 2026
…12401)

Manual roll Flutter from 2757a77a73df to e52f01c920ad (47 revisions)

Manual roll requested by [email protected]

flutter/flutter@2757a77...e52f01c

2026-07-31 [email protected] [Impeller] Execute PipelineCompileQueue jobs in the order that they were added (flutter/flutter#190262)
2026-07-31 [email protected] Roll Packages from 7d17fc8 to 5351d8c (5 revisions) (flutter/flutter#190351)
2026-07-31 [email protected] Roll Skia from dcbd015c9646 to 7ef86a5b0eb9 (4 revisions) (flutter/flutter#190347)
2026-07-31 [email protected] [Impeller] Do not acquire an unneeded image in KHRSwapchainVK if the swapchain must be recreated due to a size change (flutter/flutter#190116)
2026-07-31 [email protected] Remove the --enable-serial-gc engine flag (flutter/flutter#190310)
2026-07-31 [email protected] Migrate platform_channel_swift example to material_ui (flutter/flutter#190308)
2026-07-31 [email protected] macOS: Set static text accessibility role for read-only text fields (flutter/flutter#190330)
2026-07-31 [email protected] Roll Dart SDK from 96f49fc43f59 to c3acfc2479f6 (1 revision) (flutter/flutter#190336)
2026-07-31 [email protected] Roll Skia from 07f08414dd66 to dcbd015c9646 (1 revision) (flutter/flutter#190333)
2026-07-31 [email protected] [web] Autofill all AutofillGroup fields in semantics mode (flutter/flutter#187108)
2026-07-31 [email protected] iOS: Configure test task runner thread at display QoS (flutter/flutter#190283)
2026-07-31 [email protected] Roll Skia from a1109355de78 to 07f08414dd66 (5 revisions) (flutter/flutter#190328)
2026-07-31 [email protected] Support reduceMotion accessibility feature in MediaQuery (flutter/flutter#190287)
2026-07-30 [email protected] Roll Dart SDK from 43f7de5f4977 to 96f49fc43f59 (4 revisions) (flutter/flutter#190312)
2026-07-30 [email protected] fix: text selection two handles directionality. (flutter/flutter#179928)
2026-07-30 [email protected] Add java/gradle check when gradle crashes (flutter/flutter#189997)
2026-07-30 [email protected] [Impeller] Add filterQuality support to ImageFilter.shader (flutter/flutter#188544)
2026-07-30 [email protected] [flutter/flutter] Migrate multiple_windows example to material_ui (flutter/flutter#190313)
2026-07-30 [email protected] Roll Skia from 50cf67910462 to a1109355de78 (6 revisions) (flutter/flutter#190306)
2026-07-30 [email protected] Migrate swift xctests to Swift testing tests (flutter/flutter#187801)
2026-07-30 [email protected] Migrates the platform_channel example to material_ui (flutter/flutter#190253)
2026-07-30 [email protected] iOS: Drop unnecessary @mainactor from VSyncClientTests (flutter/flutter#190285)
2026-07-30 [email protected] Add nullptr check to isOpaque (flutter/flutter#189796)
2026-07-30 [email protected] [Flutter GPU] Bind uniforms and textures by cached reflection index (flutter/flutter#189820)
2026-07-30 [email protected] Migrate layers example to material_ui (flutter/flutter#190237)
2026-07-30 [email protected] Add `ShapeBorder` hit test fast paths (flutter/flutter#187962)
2026-07-30 [email protected] ci: mac-must-wait part duex (flutter/flutter#190295)
2026-07-30 [email protected] Roll Skia from 491301f393d1 to 50cf67910462 (3 revisions) (flutter/flutter#190294)
2026-07-30 [email protected] Roll Packages from dd11626 to 7d17fc8 (1 revision) (flutter/flutter#190293)
2026-07-30 [email protected] Roll Skia from 177de1940bf2 to 491301f393d1 (1 revision) (flutter/flutter#190279)
2026-07-30 [email protected] Roll Skia from b8bda91f02db to 177de1940bf2 (5 revisions) (flutter/flutter#190272)
2026-07-30 [email protected] Roll Fuchsia Linux SDK from J8rVTlBnjnUpuHYk3... to _J8wM3kyQpLN9wvRD... (flutter/flutter#190273)
2026-07-30 [email protected] Roll Skia from 78afc18c9ba0 to b8bda91f02db (3 revisions) (flutter/flutter#190268)
2026-07-30 [email protected] Revert: Split the platform and cpuArch part of TargetPlatform (flutter/flutter#190258)
2026-07-30 [email protected] Return null from RenderProxyBoxMixin.computeDryBaseline when the child has no baseline (flutter/flutter#189723)
2026-07-30 [email protected] Roll Skia from 6fea713d32ec to 78afc18c9ba0 (4 revisions) (flutter/flutter#190257)
2026-07-30 [email protected] Roll pub packages (flutter/flutter#190259)
2026-07-29 [email protected] [cross imports] Check examples cross imports (flutter/flutter#187662)
2026-07-29 [email protected] ci: mac verify binaries still has to wait on linux_host_engine (flutter/flutter#190239)
2026-07-29 [email protected] Adds analytics to macos impeller opt in/out (flutter/flutter#190220)
2026-07-29 [email protected] Roll Skia from 0f35bba4945c to 6fea713d32ec (6 revisions) (flutter/flutter#190230)
2026-07-29 [email protected] iOS: Fix Swift warning in TracingTests (flutter/flutter#190203)
2026-07-29 [email protected] Convert all gradle-wrapper.properties in /dev to use distribution 'bin' (flutter/flutter#190226)
2026-07-29 [email protected] Roll Packages from 3e63635 to dd11626 (11 revisions) (flutter/flutter#190216)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: desktop Running on desktop CICD Run CI/CD platform-ios iOS applications specifically platform-linux Building on or for Linux specifically platform-macos Building on or for macOS specifically platform-windows Building on or for Windows specifically team-android Owned by Android platform team team-ios Owned by iOS platform team team-linux Owned by the Linux platform team team-macos Owned by the macOS platform team team-windows Owned by the Windows platform team tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mac_arm64 build_ios_framework_module_test failing: file not found app.darwin-x86_64.symbols

3 participants