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

[SR-15432] Hashable synthesis should add nonisolated keyword for conforming actors #57738

Closed
WowbaggersLiquidLunch opened this issue Nov 3, 2021 · 3 comments

Comments

@WowbaggersLiquidLunch
Copy link
Collaborator

@WowbaggersLiquidLunch WowbaggersLiquidLunch commented Nov 3, 2021

Previous ID SR-15432
Radar rdar://problem/85004437
Original Reporter @WowbaggersLiquidLunch
Type New Feature
Status Closed
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler, Standard Library
Labels New Feature
Assignee @ktoso
Priority Medium

md5: bed5a89f4e803a1b4d508284ed284e0f

Issue Description:

relevant forum thread: https://forums.swift.org/t/hashable-actors/53199

When an actor satisfies a synchronous requirement (such as Hashable’s hash(into:) and hashValue), the witness must be nonisolated. This presents a problem for Hashable conformance:

Since Swift 4.2, the user implements either the Hasher-based hash(into:) or the deprecated hashValue, and the compiler synthesises the other that uses the user-implemented one (see the Source Compatibility section of SE-206). Because currently the synthesised code doesn’t have “nonisolated” keyword when the conforming type is an actor, the user is prompted with a warning that asks them to add “nonisolated” to the compiler-synthesised part. This results in the user having to implement both parts of the conformance. In addition to negating the benefits of having automatic Hashable synthesis, for someone not familiar with how hash(into:) and hashValue work together, it can lead to incorrect implementation.

@ktoso
Copy link
Member

@ktoso ktoso commented Nov 4, 2021

Hmmm, this sounds off.. I implemented Hashable on actors and seemed to work... we'll look into it, thanks

@swift-ci create

@DougGregor
Copy link
Member

@DougGregor DougGregor commented Nov 5, 2021

@WowbaggersLiquidLunch
Copy link
Collaborator Author

@WowbaggersLiquidLunch WowbaggersLiquidLunch commented Nov 5, 2021

Just tested it, and can confirm that this has been fixed in the trunk.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants