Skip to content

[6.0] Add support for swift-collections 1.1 #7614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jmschonfeld
Copy link
Contributor

Cherry pick of #7607

Explanation: SwiftPM fails to build against [email protected], this change allows SwiftPM to be compatible with both [email protected] and [email protected]
Scope: Isolated to one specific line where the build failure occurred and initializes the return value to an Array explicitly
Risk: Low as the change is minimal and has been validated via testing
Testing: Existing SwiftPM testing has passed and I have been able to build a toolchain locally with the change
Reviewer: @MaxDesiatov

This PR makes a necessary update to the source in order to support
building against swift-collections 1.1

### Motivation:

swift-collections added a new API in v1.1:

```swift
extension OrderedSet {
  @inlinable
  public func filter(
    _ isIncluded: (Element) throws -> Bool
  ) rethrows -> Self
}
```

swift-package-manager was previously calling `filter` on an `OrderedSet`
and expecting to get back an `Array` (via the extension on `Sequence`)
however with this new swift-collections change, the returned value of
`filter` became an `OrderedSet`. This caused build failures when the
`+=` operator (which exists for `Array` but not `OrderedSet` operands)
was used on the return value.

We should update this code to support swift-collections 1.1 so that we
can begin using swift-collections 1.1 in toolchain builds.

### Modifications:

The code is updated to convert the return type of `filter` to an `Array`

### Result:

The same source will now successfully compile against both
swift-collections 1.0.x and 1.1.x
@jmschonfeld
Copy link
Contributor Author

@swift-ci please test

@jmschonfeld
Copy link
Contributor Author

@swift-ci please smoke test Linux platform

@jmschonfeld
Copy link
Contributor Author

@swift-ci please test linux platform

@jmschonfeld jmschonfeld merged commit 7f8c72e into swiftlang:release/6.0 May 31, 2024
5 checks passed
@jmschonfeld jmschonfeld deleted the swift-collections-1-1-cherrypick branch May 31, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants