You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// enums with non-conforming payloads don’t get synthesized Comparable
340
-
enumNotice:Comparable{ // expected-error{{type 'Notice' does not conform to protocol 'Comparable'}} expected-error{{type 'Notice' does not conform to protocol 'Equatable'}}
341
-
case taylor((Int,Int)), taylornation(Int) // expected-note{{associated value type '(Int, Int)' does not conform to protocol 'Equatable', preventing synthesized conformance of 'Notice' to 'Equatable'}}
342
-
}
343
-
344
-
// neither do enums with raw values
345
-
enumTrack:Int,Comparable{ // expected-error{{type 'Track' does not conform to protocol 'Comparable'}}
// Automatic synthesis of Comparable is only supported for enums for now.
4
+
5
+
structNotComparableStruct:Comparable{
6
+
// expected-error@-1 {{type 'NotComparableStruct' does not conform to protocol 'Comparable'}}
7
+
// expected-note@-2 {{automatic synthesis of 'Comparable' is not supported for structs}}
8
+
varvalue=0
9
+
}
10
+
11
+
classNotComparableClass:Comparable{
12
+
// expected-error@-1 {{type 'NotComparableClass' does not conform to protocol 'Comparable'}}
13
+
// expected-note@-2 {{automatic synthesis of 'Comparable' is not supported for classes}}
14
+
// expected-error@-3 {{type 'NotComparableClass' does not conform to protocol 'Equatable'}}
15
+
// expected-note@-4 {{automatic synthesis of 'Equatable' is not supported for classes}}
16
+
varvalue=1
17
+
}
18
+
19
+
// Automatic synthesis of Comparable requires enum without raw type.
20
+
21
+
enumNotComparableEnumOne:Int,Comparable{
22
+
// expected-error@-1 {{type 'NotComparableEnumOne' does not conform to protocol 'Comparable'}}
23
+
// expected-note@-2 {{enum declares raw type 'Int', preventing synthesized conformance of 'NotComparableEnumOne' to 'Comparable'}}
24
+
case value
25
+
}
26
+
27
+
// Automatic synthesis of Comparable requires associated values to be Comparable as well.
28
+
29
+
enumNotComparableEnumTwo:Comparable{
30
+
// expected-error@-1 {{type 'NotComparableEnumTwo' does not conform to protocol 'Comparable'}}
31
+
structNotComparable:Equatable{}
32
+
case value(NotComparable)
33
+
// expected-note@-1 {{associated value type 'NotComparableEnumTwo.NotComparable' does not conform to protocol 'Comparable', preventing synthesized conformance of 'NotComparableEnumTwo' to 'Comparable'}}
0 commit comments