[Swift] Migrate Swift runtime to Swift 5. #2686
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.
This switches from using the deprecated hashValue to hash(into:). It also switches from using index to firstIndex (matching the change in the standard library).
In the test template, we switch to using String directly instead of String.characters.
Replace all uses of NSStringFromClass. Bridging from NSString to String in Swift 5 is a transcoding operation, so it is expensive. Use String(describing:) instead of NSStringFromClass to avoid this cost.
Change the generation of the copyFrom method to work around SR-10260:
This bug in Swift 5's compiler causes a SIL verification error when calling super.foo without overriding foo in the subclass. In our case, we are generating a copyFrom implementation in the subclass, and calling super.copyFrom. Crucially, the subclass implementation uses the context subtype for the argument, which means that it doesn't actually override the superclass's implementation. This then tickles the SIL verification bug.
Work around this by changing our autogenerated copyFrom definition to use ParserRuleContext as the argument type. This means that it actually overrides the implementation in ParserRuleContext, and so the super.copyFrom call is generated correctly.
Change many uses of var to let, to fix compiler warnings in Swift 5.1. This work is from Mark Lilback mark@lilback.com.
This also switches all the Travis macOS tests to use the Xcode 10.2 / Mojave image and changes the Linux Swift tests to download Swift 5.0.1.