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
Assignees
Labels
actor Feature → concurrency: `actor` declarations bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances Hashable Area → standard library: The `Hashable` protocol unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@WowbaggersLiquidLunch
Copy link
Collaborator

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 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

#38620

@WowbaggersLiquidLunch
Copy link
Collaborator Author

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
@AnthonyLatsis AnthonyLatsis added Hashable Area → standard library: The `Hashable` protocol feature A feature request or implementation conformances Feature → protocol: protocol conformances derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. unexpected behavior Bug: Unexpected behavior or incorrect output actor Feature → concurrency: `actor` declarations and removed new feature standard library Area: Standard library umbrella feature A feature request or implementation labels Feb 25, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actor Feature → concurrency: `actor` declarations bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conformances Feature → protocol: protocol conformances derived conformances Feature → protocol → conformances: derived conformances aka synthesized conformances Hashable Area → standard library: The `Hashable` protocol unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

4 participants