Context
I have an Enum
where one of its Cases
has an Optional Protocol Type
as one of its Associated Types
. Since adding this new Associated Type
, I get the following Compiler Error
:
Compiler Error #1: Type 'MyEnum' does not conform to protocol 'Equatable'
Compiler Error #2: Type 'MyEnum' does not conform to protocol 'Hashable'
Code
protocol Component { ... }
enum MyEnum: Hashable, Identifiable {
var id: Int { hashValue }
case myCase1
case myCase2(value: Int? = nil)
case myCase3(component: (any Component)? = nil) // Adding this Case breaks the Code.
}
Question
How can I solve the Compiler Errors
above and support an Optional Protocol Type
as an Associated Type
for an Enum Case
?