Skip to content

[4.1][stdlib] Remove the unnecessary compactMap overload #14779

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 2 commits into from
Feb 23, 2018

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Feb 21, 2018

  • Explanation: Remove an unnecessary overlad that was introduced by mistake.
  • Risk: Minimal, as compactMap were introduced only recently
  • Reviewed By: Ben Cohen
  • Testing: Automated test suite + compatibility test suite
  • Directions for QA: N/A
  • Radar: rdar://problem/37764446

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)
@moiseev
Copy link
Contributor Author

moiseev commented Feb 21, 2018

@swift-ci Please test

@moiseev
Copy link
Contributor Author

moiseev commented Feb 21, 2018

@swift-ci Please Test Source Compatibility

@moiseev
Copy link
Contributor Author

moiseev commented Feb 21, 2018

@swift-ci Please nominate

@moiseev
Copy link
Contributor Author

moiseev commented Feb 22, 2018

@swift-ci Please test

@swiftlang swiftlang deleted a comment from swift-ci Feb 22, 2018
@swiftlang swiftlang deleted a comment from swift-ci Feb 22, 2018
@moiseev
Copy link
Contributor Author

moiseev commented Feb 22, 2018

@swift-ci Please Test Source Compatibility

1 similar comment
@moiseev
Copy link
Contributor Author

moiseev commented Feb 22, 2018

@swift-ci Please Test Source Compatibility

@najacque najacque merged commit 64f8b5b into swiftlang:swift-4.1-branch Feb 23, 2018
@moiseev moiseev deleted the no-weird-overload-4 branch February 23, 2018 18:04
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