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-9827] Struct with weak or unowned member does not synthesize Equatable #52244

swift-ci opened this issue Jan 31, 2019 · 1 comment


Copy link

swift-ci commented Jan 31, 2019

Previous ID SR-9827
Radar None
Original Reporter dlindenkreuz (JIRA User)
Type Bug
Status Resolved
Resolution Done

Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)

Target: x86_64-apple-darwin18.2.0

Xcode 10.1 (10B61)

Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: e7d432e8a93e75b0ee6765f4c0d4397c

Issue Description:

When adopting Equatable in a struct, Swift usually synthesizes Equatable conformance if all struct members are Equatable as well. However, this seems to stop working when declaring a member as weak var or unowned var:

// Error: Type 'Foo' does not conform to protocol 'Equatable'
struct Foo: Equatable {
    weak var x: Bar? // Removing `weak` fixes above error, type `Bar?` is fine
    var y: String

class Bar: Equatable {
    static func == (lhs: Bar, rhs: Bar) -> Bool {
        return true

Expected behaviour:

Swift should synthesize Equatable conformance for a type when all its members conform to Equatable, regardless of the members' storage types (unowned or weak).

(Related forum thread:

Copy link

theblixguy commented Jan 31, 2019

It’s fixed on master: #22143

@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
None yet

No branches or pull requests

2 participants