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'structFoo: Equatable {
weakvarx: Bar? // Removing `weak` fixes above error, type `Bar?` is finevary: String
}
classBar: Equatable {
staticfunc == (lhs: Bar, rhs: Bar) -> Bool {
returntrue
}
}
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).
swift-ci commentedJan 31, 2019
Environment
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
md5: e7d432e8a93e75b0ee6765f4c0d4397c
Issue Description:
When adopting
Equatable
in a struct, Swift usually synthesizesEquatable
conformance if all struct members areEquatable
as well. However, this seems to stop working when declaring a member asweak var
orunowned var
:Expected behaviour:
Swift should synthesize
Equatable
conformance for a type when all its members conform toEquatable
, regardless of the members' storage types (unowned or weak).(Related forum thread: https://forums.swift.org/t/struct-with-weak-member-prevents-synthesized-equatable/19778)
The text was updated successfully, but these errors were encountered: