Skip to content

[5.0][stdlib] Remove the unnecessary compactMap overload #14804

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

Merged
merged 1 commit into from
Feb 24, 2018

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Feb 23, 2018

This particular overload of compactMap was mechanically copied from the
flatMap while implementing SE-0187, but as community members correctly
noticed on the forum thread
here,
there is no code that we should be backward compatible with, since
compactMap has only been introduced recently.

After applying this change, the following code is correctly ambiguous
again:

[].compactMap { _ in nil } // error: 'nil' requires a contextual type

as opposed to:

[].flatMap { _ in nil } // r0 : [String] = []

Fixes: https://bugs.swift.org/browse/SR-7052 (rdar://problem/37764446)
(cherry picked from commit 9d70574)
(cherry picked from commit b9ed475)

This particular overload of compactMap was mechanically copied from the
`flatMap` while implementing SE-0187, but as community members correctly
noticed on the forum thread
[here](https://forums.swift.org/t/why-is-there-a-collection-flatmap-that-takes-a-closure-returning-string/10141),
there is no code that we should be backward compatible with, since
`compactMap` has only been introduced recently.

After applying this change, the following code is correctly ambiguous
again:

```swift
[].compactMap { _ in nil } // error: 'nil' requires a contextual type
```

as opposed to:

```swift
[].flatMap { _ in nil } // r0 : [String] = []
```

Fixes: https://bugs.swift.org/browse/SR-7052
(cherry picked from commit 9d70574)
(cherry picked from commit b9ed475)
@moiseev
Copy link
Contributor Author

moiseev commented Feb 23, 2018

@swift-ci Please smoke test and merge

1 similar comment
@najacque
Copy link
Contributor

@swift-ci Please smoke test and merge

@moiseev
Copy link
Contributor Author

moiseev commented Feb 23, 2018

@najacque the 5.0 branch is a little broken on Linux right now. I talked to Jordan and he'll cherry-pick the necessary changes shortly.
UPD: The fix is here

@jrose-apple
Copy link
Contributor

@swift-ci Please smoke test Linux

@moiseev
Copy link
Contributor Author

moiseev commented Feb 23, 2018

@swift-ci Please smoke test Linux platform

@moiseev moiseev merged commit 843a33f into swiftlang:swift-5.0-branch Feb 24, 2018
@moiseev moiseev deleted the no-weird-overload-5 branch February 24, 2018 00:01
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.

3 participants