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
[NFC] Replace PackageConditionProtocol with PackageCondition (#7117)
Unblocks `PackageGraph` value types refactoring in
#7160 and macros
cross-compilation fix in
#7118.
Multiple places in our codebase pass around and store `[any
PackageConditionProtocol]` arrays of existentials with `FIXME` notes
that those should be sets and not arrays.
We also can't convert types containing these arrays to value types with
auto-generated `Hashable` conformance, since neither elements of these
arrays nor arrays themselves are `Hashable`. Adding `Hashable`
requirement to `PackageConditionProtocol` doesn't fix the issue, since
existentials of this protocol still wouldn't conform to `Hashable`.
A simple alternative is to create `enum PackageCondition` with cases for
each condition type. We only have two of those types and they're always
declared in the same module. There's no use case for externally defined
types for this protocol. That allows us to convert uses of `[any
PackageConditionProtocol]` to `[PackageCondition]`. Existing protocol is
kept around until clients of SwiftPM can migrate to the new
`PackageCondition` enum.
This also allows us to remove a custom conformance to `Hashable` on
`ResolvedTarget`, unblocking a conversion of `ResolvedTarget` to a value
type and making it `Sendable` in the future.
0 commit comments