Make tests compatible with Swift 5 #605
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Newer versions of Swift have improved nil coalescing (SE-0230). Unfortunately, this breaks our code.
Consider the following:
Here
encrypter
isTSMessage?
and then wetry?
to convert the error into an optional when acting on an optionalencrypter
. In Swift 4verifiedMessage
hasData??
type but Swift 5 flattens the optional chain and returnsData?
instead. We cannotunwrap!!
that twice.Update the tests to handle
nil
values more explicitly and avoid optional chaining withtry?
. This results in code that compiles correctly with both Swift 4 & 5.P.S. Existing CocoaPods-based test project uses Swift 4 so the issue is not visible there. However, try updating the version and you'll see it.
Checklist