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
// ...and they should also inherit equatability from Hashable.
117
127
ifEnumWithHashablePayload.A(1)==.B("x",1){}
118
128
ifEnumWithHashablePayload.A(1)==.C {}
@@ -135,12 +145,13 @@ var genericHashableHash: Int = GenericHashable<String>.A("a").hashValue
135
145
136
146
// But it should be an error if the generic argument doesn't have the necessary
137
147
// constraints to satisfy the conditions for derivation.
138
-
enumGenericNotHashable<T:Equatable>:Hashable{ // expected-error {{does not conform}}
148
+
enumGenericNotHashable<T:Equatable>:Hashable{ // expected-error 2 {{does not conform to protocol 'Hashable'}}
139
149
case A(T)
140
150
case B
141
151
}
142
152
ifGenericNotHashable<String>.A("a")==.B {}
143
-
vargenericNotHashableHash:Int=GenericNotHashable<String>.A("a").hashValue // expected-error {{value of type 'GenericNotHashable<String>' has no member 'hashValue'}}
153
+
let _:Int=GenericNotHashable<String>.A("a").hashValue // No error. hashValue is always synthesized, even if Hashable derivation fails
154
+
GenericNotHashable<String>.A("a").hash(into:&hasher) // expected-error {{value of type 'GenericNotHashable<String>' has no member 'hash'}}
144
155
145
156
// An enum with no cases should not derive conformance.
146
157
enumNoCases:Hashable{} // expected-error 2 {{does not conform}}
vargenericNotHashableHash:Int=GenericNotHashable<String>(value:"a").hashValue // expected-error {{value of type 'GenericNotHashable<String>' has no member 'hashValue'}}
145
+
letgnh=GenericNotHashable<String>(value:"b")
146
+
let _:Int= gnh.hashValue // No error. hashValue is always synthesized, even if Hashable derivation fails
147
+
gnh.hash(into:&hasher) // expected-error {{value of type 'GenericNotHashable<String>' has no member 'hash'}}
113
148
114
149
115
150
// Conformance cannot be synthesized in an extension.
0 commit comments