here’s a simple example of a pair of conditional conformances to Hashable
and Equatable
:
public
enum Generic<T>
{
case value(T)
}
extension Generic:Equatable where T:Equatable
{
}
extension Generic:Hashable where T:Hashable
{
}
the way i always understood conditional conformances to Hashable
is it does not include the implied conformance to Hashable
’s superprotocol Equatable
; it needs to be specified explicitly, or declared on a different extension block with different generic constraints.
and yet when i explore the symbolgraph for this example program, i see three conformances: one Hashable
conformance, and two Equatable
conformances:
"relationships": [
{
"kind": "conformsTo",
"source": "s:24GenericEquatableHashable0A0O",
"target": "s:SH",
"targetFallback": "Swift.Hashable",
"swiftConstraints": [
{
"kind": "conformance",
"lhs": "T",
"rhs": "Hashable",
"rhsPrecise": "s:SH"
}
]
},
{
"kind": "memberOf",
"source": "s:24GenericEquatableHashable0A0O5valueyACyxGxcAEmlF",
"target": "s:24GenericEquatableHashable0A0O"
},
{
"kind": "conformsTo",
"source": "s:24GenericEquatableHashable0A0O",
"target": "s:SQ",
"targetFallback": "Swift.Equatable",
"swiftConstraints": [
{
"kind": "conformance",
"lhs": "T",
"rhs": "Equatable",
"rhsPrecise": "s:SQ"
}
]
},
{
"kind": "conformsTo",
"source": "s:24GenericEquatableHashable0A0O",
"target": "s:SQ",
"targetFallback": "Swift.Equatable",
"swiftConstraints": [
{
"kind": "conformance",
"lhs": "T",
"rhs": "Hashable",
"rhsPrecise": "s:SH"
}
]
}
]
where is the last conformance (Equatable where T:Hashable
) coming from?