Skip to content

[stdlib] Adding a deprecated version of flatMap to warn misuses. #7823

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
Mar 6, 2017

Conversation

moiseev
Copy link
Contributor

@moiseev moiseev commented Feb 28, 2017

Due to implicit promotion to optional it is possible to call flatMap
with a closure, that does not return an optional. This way the code
works, but is unnecessary inefficient. Such uses of flatMap can and
should be replaced with map.

@moiseev
Copy link
Contributor Author

moiseev commented Feb 28, 2017

@swift-ci Please test

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 0198a4e58fbeaedf42727d81cc21ebfc00182ae5
Test requested by - @moiseev

@swift-ci
Copy link
Contributor

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 0198a4e58fbeaedf42727d81cc21ebfc00182ae5
Test requested by - @moiseev

@airspeedswift
Copy link
Member

airspeedswift commented Mar 2, 2017

Should this really be an error or just a warning?

edit: sorry I see it is just a warning. The test is failing with an error tho.

@moiseev
Copy link
Contributor Author

moiseev commented Mar 2, 2017

@airspeedswift Yeah, -verify mode treats unexpected warnings as errors. Fixing the tests is on my list.

Due to implicit promotion to optional it is possible to call flatMap
with a closure, that does not return an optional. This way the code
works, but is unnecessary inefficient. Such uses of flatMap can and
should be replaced with map.
@moiseev
Copy link
Contributor Author

moiseev commented Mar 3, 2017

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Mar 3, 2017

Build failed
Jenkins build - Swift Test Linux Platform
Git Commit - 0198a4e58fbeaedf42727d81cc21ebfc00182ae5
Test requested by - @moiseev

@swift-ci
Copy link
Contributor

swift-ci commented Mar 3, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - 0198a4e58fbeaedf42727d81cc21ebfc00182ae5
Test requested by - @moiseev

@moiseev moiseev merged commit 98e6caf into swiftlang:master Mar 6, 2017
@moiseev moiseev deleted the nonopt-flatmap branch March 6, 2017 18:16
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