Skip to content
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

Mark enums as Sendable #165

Merged
merged 1 commit into from
Apr 18, 2024
Merged

Mark enums as Sendable #165

merged 1 commit into from
Apr 18, 2024

Conversation

tristanlabelle
Copy link
Contributor

@tristanlabelle tristanlabelle commented Apr 18, 2024

WinRT enums are integers in disguise and projected as typealiases for C enums, so they are always Sendable.

@tristanlabelle tristanlabelle requested a review from a team as a code owner April 18, 2024 16:04
@tristanlabelle tristanlabelle merged commit d34f77a into main Apr 18, 2024
1 check passed
@tristanlabelle tristanlabelle deleted the tristan/make-enums-sendable branch April 18, 2024 16:14
@mliberman
Copy link

mliberman commented Apr 19, 2024

Retroactive Sendable conformance also needs to be @unchecked. Seeing these warnings after this change:

...\Windows.Foundation.swift:731:1: warning: conformance to 'Sendable' must occur in the same source file as struct '__x_ABI_CWindows_CFoundation_CAsyncStatus'; use '@unchecked Sendable' for retroactive conformance; this is an error in the Swift 6 language mode

@tristanlabelle
Copy link
Contributor Author

@mliberman See https://github.com/thebrowsercompany/arc/pull/25526 . Swift is inconsistent here >.>

@@ -48,7 +48,7 @@ namespace swiftwinrt
}
w.write("}\n");

w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable {}\n\n", get_full_swift_type_name(w, type));
w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable, ^@retroactive Sendable {}\n\n", get_full_swift_type_name(w, type));

Choose a reason for hiding this comment

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

@tristanlabelle i.e. I think this needs to be

Suggested change
w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable, ^@retroactive Sendable {}\n\n", get_full_swift_type_name(w, type));
w.write("extension %: ^@retroactive Hashable, ^@retroactive Codable, ^@retroactive @unchecked Sendable {}\n\n", get_full_swift_type_name(w, type));
Comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes probably, will update. It's a bummer that Swift is inconsistent.

Choose a reason for hiding this comment

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

🤔 it doesn't seem inconsistent to me, I think the error message is just poorly worded.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I think I get it but yeah the message is misleading because @retroactive allows the conformance to be in a different module, which seems like a superset of @unchecked which is described as allowing the conformance to be in a different file.

conformance to 'Sendable' must occur in the same source file as struct '__x_ABI_CArcCoreWinRT_CAdhocHistogramType'; use '@unchecked Sendable' for retroactive conformance; this is an error in the Swift 6 language mode",

kendalharland pushed a commit that referenced this pull request Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants