Skip to content

[pigeon] [swift] Fix PigeonError sendability conformance in Swift 6 #8302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 3, 2025

Conversation

bc-lee
Copy link
Contributor

@bc-lee bc-lee commented Dec 15, 2024

Ensure PigeonError conforms to Sendable for Swift 6.0 compatibility by updating the details property type from Any? to Sendable?.

Fixes flutter/flutter#160313

Pre-launch Checklist

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

@hellohuanlin
Copy link
Contributor

This will break old sdk where Sendable is undefined. You may have to put it behind a flag.

@bc-lee
Copy link
Contributor Author

bc-lee commented Dec 15, 2024

This will break old sdk where Sendable is undefined. You may have to put it behind a flag.

Are there any minimum Xcode requirements for Flutter projects? Sendable was added in Xcode 13.0 with Swift 5.5.

@bc-lee
Copy link
Contributor Author

bc-lee commented Dec 15, 2024

I found the answer.

  • Flutter 3.12 or later requires Xcode 14.0 or newer.
    Source
  • Flutter 3.0 or later requires Xcode 13.0 or newer.
    Source

So, I think it is safe to use this in Pigeon, as Pigeon requires Dart 3.3 and Flutter 3.19.

@@ -1,6 +1,7 @@
## NEXT
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be updated to 22.7.1 along with the pubspec version and the generator_tools file.

I guess this is technically a breaking change, so 23.0.0 might be more correct.

@@ -1,6 +1,7 @@
## NEXT

* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.
* [swift] Make `PigeonError` Class Conform to `Sendable`
Copy link
Contributor

Choose a reason for hiding this comment

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

[swift] Changes `PigeonError` class to conform to `Sendable`.

@tarrinneal
Copy link
Contributor

@stuartmorgan shouldn't this pr be failing the test exemption check?

Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

lgtm after addressing the comments.

@bc-lee bc-lee changed the title [pigeon][swift] Make PigeonError Class Conform to Sendable [pigeon] [swift] Changes PigeonError class to conform to Sendable. Dec 19, 2024
@bc-lee bc-lee requested a review from tarrinneal December 19, 2024 22:56
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

@stuartmorgan shouldn't this pr be failing the test exemption check?

I think there's a false negative due to the changes to generated files in platform_tests; we should probably tune the Cocoon rules to ignore .gen. files in there.

Regardless, this does need testing. A Dart unit test should be fine for this for now (although long term we probably want to adjust the Swift integration tests to actually test a flow that ensures that everything is Sendable)

@bc-lee
Copy link
Contributor Author

bc-lee commented Dec 27, 2024

Regardless, this does need testing. A Dart unit test should be fine for this for now (although long term we probably want to adjust the Swift integration tests to actually test a flow that ensures that everything is Sendable)

I have added the Dart test introduced by this PR. I also agree that the long-term solution would involve updating the Swift integration tests—not just to check for @Sendable, but to cover all aspects related to Swift's strict concurrency model. However, I believe this would require additional setup.

Copy link
Contributor

@tarrinneal tarrinneal left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together, looks good to merge to me.

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 14, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 14, 2025
Copy link
Contributor

auto-submit bot commented Jan 14, 2025

auto label is removed for flutter/packages/8302, due to This PR has not met approval requirements for merging. Changes were requested by {stuartmorgan}, please make the needed changes and resubmit this PR.
The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@tarrinneal
Copy link
Contributor

@stuartmorgan you'll need to approve this one to land it.

@@ -1,3 +1,7 @@
## 23.0.0

* [swift] Changes `PigeonError` class to conform to `Sendable`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Breaking changes need to follow the CHANGELOG style guide for breaking changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@hellohuanlin hellohuanlin Jan 31, 2025

Choose a reason for hiding this comment

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

I don't think change log is accurate, because PigeonError already conforms to Error before this PR (and Errors are by design Sendable). This PR does not change this conformance.

How about "Fixes a compile error about PigeonError's sendability conformance in Swift 6"?

Copy link
Contributor

Choose a reason for hiding this comment

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

If it was already Sendable, why would we need to change Any? to Sendable? I'm confused.

Copy link
Contributor

Choose a reason for hiding this comment

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

The PigeonError type itself was Sendable, but its details field was not Sendable, hence the compile error in Swift 6 (or compile warning in Swift 5's strict mode).

That being said, this PR is still a breaking change tho, because the init signature is changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the delay—I was on a national holiday.

Yes, the above discussion is correct. PigeonError already conforms to Error, which also makes it Sendable. However, the type of its details field prevents it from conforming under Strict Concurrency, leading to a compilation error in Swift 6.

@tarrinneal tarrinneal dismissed stuartmorgan-g’s stale review January 31, 2025 19:20

Fixes made, enough reviews to land

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Jan 31, 2025
@hellohuanlin hellohuanlin removed the autosubmit Merge PR when tree becomes green via auto submit App label Jan 31, 2025
Copy link
Contributor

@hellohuanlin hellohuanlin left a comment

Choose a reason for hiding this comment

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

Sorry for the block (I removed autosubmit tag), just saw the discussion on CHANGELOG and left a comment there: #8302 (comment)

@tarrinneal
Copy link
Contributor

Sorry for the block (I removed autosubmit tag), just saw the discussion on CHANGELOG and left a comment there: #8302 (comment)

I fixed that, can you approve so we can land?

@bc-lee bc-lee changed the title [pigeon] [swift] Changes PigeonError class to conform to Sendable. [pigeon] [swift] Fix PigeonError sendability conformance in Swift 6 Jan 31, 2025
@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 3, 2025
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 3, 2025
Copy link
Contributor

auto-submit bot commented Feb 3, 2025

autosubmit label was removed for flutter/packages/8302, because This PR has not met approval requirements for merging. Changes were requested by {stuartmorgan}, please make the needed changes and resubmit this PR.
The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@tarrinneal
Copy link
Contributor

autosubmit label was removed for flutter/packages/8302, because This PR has not met approval requirements for merging. Changes were requested by {stuartmorgan}, please make the needed changes and resubmit this PR. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@stuartmorgan not sure what the deal is here. I did "invalidate" your review since it had been addressed. Might be related.

@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 3, 2025
Copy link
Contributor

auto-submit bot commented Feb 3, 2025

autosubmit label was removed for flutter/packages/8302, because This PR has not met approval requirements for merging. Changes were requested by {stuartmorgan}, please make the needed changes and resubmit this PR.
The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a flutter-hacker before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Feb 3, 2025
Copy link
Contributor

@stuartmorgan-g stuartmorgan-g left a comment

Choose a reason for hiding this comment

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

Weird, seems like a Cocoon bug one way or another.

@stuartmorgan-g stuartmorgan-g added the autosubmit Merge PR when tree becomes green via auto submit App label Feb 3, 2025
@auto-submit auto-submit bot merged commit 3960c96 into flutter:main Feb 3, 2025
77 checks passed
@bc-lee bc-lee deleted the feature/pigeon-error-sendable branch February 3, 2025 20:12
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 5, 2025
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Feb 5, 2025
flutter/packages@02c6fef...e6ce02c

2025-02-05 [email protected] [vector_graphics]
Allow transition between placeholder and loaded image to have an
animation (flutter/packages#8195)
2025-02-04 [email protected] [flutter_markdown] Make custom table
column alignments work when text wraps (flutter/packages#8340)
2025-02-04 [email protected]
[interactive_media_ads] Adds internal wrapper for iOS native
`IMAAdPodInfo` (flutter/packages#8429)
2025-02-03 [email protected] [pigeon] reorg generator files
(flutter/packages#8532)
2025-02-03 [email protected] [pigeon] [swift] Fix `PigeonError`
sendability conformance in Swift 6 (flutter/packages#8302)
2025-02-03 [email protected] Roll Flutter from
b007899 to 8e2a6fc (61 revisions) (flutter/packages#8556)
2025-02-03 [email protected]
[google_maps_flutter] Support for Ground Overlay - platform interface
(flutter/packages#8518)
2025-01-31 [email protected] [tool] Add
--xcode-warnings-exceptions flag (flutter/packages#8524)
2025-01-31 [email protected] [tool] Ensure that injected
dependency overrides are sorted (flutter/packages#8542)
2025-01-31 [email protected] [vector_graphics] Revert leak
tracker change (flutter/packages#8544)
2025-01-31 [email protected] [shared_preferences_tool] Loosen
vm_service constraint to allow for 15 (flutter/packages#8539)
2025-01-31 [email protected]
[in_app_purchase] Activate leak testing for android
(flutter/packages#8369)
2025-01-31 [email protected] [flutter_markdown] Allow tables to be
scrollable with IntrinsicColumnWidth (flutter/packages#8526)
2025-01-30 [email protected] Update CODEOWNERS for pkg:animations
(flutter/packages#8534)
2025-01-30 [email protected] Roll Flutter from
c1ffaa9 to b007899 (43 revisions) (flutter/packages#8527)
2025-01-30 [email protected] [video_player_web] Adjust Web
implementation to the new platform interface (flutter/packages#8528)
2025-01-30 [email protected] [shared_preferences] Exposed
SharedPreferencesOptions. (flutter/packages#8530)
2025-01-29 [email protected] Re-land [shared_preferences] Add
shared preferences devtool (flutter/packages#8531)
2025-01-29 [email protected]
[in_app_purchase_storekit] Add Swift Package Manager compatibility
(flutter/packages#8469)
2025-01-29 [email protected] Revert "Re-land [shared_preferences]
Add shared preferences devtool" (flutter/packages#8529)
2025-01-29 [email protected]
[go_router_builder] Fixes trailing `?` by comparing iterables
(flutter/packages#8521)
2025-01-29 [email protected] [tool] Refactor
args of strings or YAML file lists (flutter/packages#8513)
2025-01-28 [email protected] [go_router]
Add missing await keyword to onTap callback in the code example in
`navigation.md` (flutter/packages#8343)
2025-01-28 [email protected] Re-land [shared_preferences] Add
shared preferences devtool (flutter/packages#8519)
2025-01-28 [email protected]
[vector_graphics] Fix memory leaks and activate leak testing
[prod-leak-fix] (flutter/packages#8373)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
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 p: pigeon platform-ios platform-macos
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pigeon][swift] Make PigeonError Class Conform to Sendable
4 participants