Skip to content
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

[Swift] Migrate Swift runtime to Swift 5. #2686

Merged
merged 4 commits into from Dec 9, 2019
Merged

Conversation

ewanmellor
Copy link
Contributor

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.

ewanmellor and others added 4 commits November 18, 2019 13:24
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.

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.
…R-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.
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.
@ewanmellor ewanmellor mentioned this pull request Dec 8, 2019
@parrt parrt added this to the 4.8 milestone Dec 9, 2019
@parrt parrt merged commit a75c3e9 into antlr:master Dec 9, 2019
@ewanmellor ewanmellor deleted the swift-5 branch December 21, 2019 04:18
@atfelix atfelix mentioned this pull request Sep 21, 2020
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants