Skip to content

Adjust for 'try?' changes in Swift 5 #1777

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
Nov 16, 2018
Merged

Conversation

bjhomer
Copy link
Contributor

@bjhomer bjhomer commented Nov 16, 2018

When 'try?' has an optional sub-expression, it no longer produces a nested optional.

When 'try?' has an optional sub-expression, it no longer produces a nested optional.
@rudkx
Copy link
Contributor

rudkx commented Nov 16, 2018

@swift-ci Please smoke test

@rudkx
Copy link
Contributor

rudkx commented Nov 16, 2018

I don't see where swift-corelibs-foundation is actually building with -swift-version 5 yet.

Also, there are a number of other uses of try? in the project - are you sure this is the only one that would need adjusting when building with -swift-version 5?

@bjhomer
Copy link
Contributor Author

bjhomer commented Nov 16, 2018

Hm. I believe we've got tests in try.swift to make sure that this behavior has not changed in Swift 4 mode. I'm not familiar with how swift-corelibs-foundation builds, but it does appear like it's using -swift-version 5 based on the behavior here.

I haven't done an exhaustive search yet, but this was the only use of try? that initially stood out. I'll keep looking.

@bjhomer
Copy link
Contributor Author

bjhomer commented Nov 16, 2018

There are only two cases of try? ... as? in swift-corelibs-foundation, and the other one (in TestNSNumber.swift) does not need to be changed. So this is the only case matching that particular pattern, which is the most common case of the try? double-optional in the wild.

@bjhomer
Copy link
Contributor Author

bjhomer commented Nov 16, 2018

I just looked at all the uses of try? in Foundation. This is the only one that needs to be changed for swift-version 5. So the question is just whether it should be building with v5 yet.

@bjhomer
Copy link
Contributor Author

bjhomer commented Nov 16, 2018

Based on the rejected PR here (https://github.com/apple/swift-corelibs-foundation/pull/1774/files), it looks like the foundation tests are using swift-version 5 by default. (The PR was to set it back to version 4, but that change was not made)

@shahmishal
Copy link
Member

@swift-ci test

@shahmishal
Copy link
Member

Merged to unblock CI.

@shahmishal shahmishal merged commit c82398a into swiftlang:master Nov 16, 2018
@rudkx
Copy link
Contributor

rudkx commented Nov 16, 2018

@bjhomer Okay, I had missed that the compiler was actually defaulting to -swift-version 5 as of yesterday, but apparently that's the case.

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