case .s(var s): // -1 for return from pattern match (total: +2) s.foo() e = .empty // -1 (total: +1) s.foo() // should be uniquely referenced
If s would be a struct which is owned by the enum, i.e. it is stored in the enum value, the above code would be quite problematic if the struct s would be referenced out of the enum and then the enum value is changed, making further access invalid.
To cicumvent the problem, the enum value fixed as switch param is duplicated behind the scenes s.t. replacing the enum value e inside the switch block would only mutate the enum value outside the switch block and not the duplicated enum value inside.
But, I don't know if these are the current semantics of Swift's switch.