[SR-15432] Hashable synthesis should add nonisolated
keyword for conforming actors
#57738
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
Additional Detail from JIRA
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
’shash(into:)
andhashValue
), the witness must benonisolated
. This presents a problem forHashable
conformance:Since Swift 4.2, the user implements either the
Hasher
-basedhash(into:)
or the deprecatedhashValue
, 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 automaticHashable
synthesis, for someone not familiar with howhash(into:)
andhashValue
work together, it can lead to incorrect implementation.The text was updated successfully, but these errors were encountered: