-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Sema: Fix assertion failure when overriding a dynamic method with a final method [4.0] #12001
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
Sema: Fix assertion failure when overriding a dynamic method with a final method [4.0] #12001
Conversation
…inal method Fixes <https://bugs.swift.org/browse/SR-5924>, <rdar://problem/34497670>.
@swift-ci Please test |
@jrose-apple I thought I cherry-picked this into 4.0 already but it looks like I didn't. Mind reviewing? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, I don't think this is correct. If a base method is dynamic
, that could mean the author expects it to be replaced at run-time. That means the overriding method has to be dynamic
as well.
Build failed |
@jrose-apple However, the override in question is explicitly 'final'. I think we should probably disallow final overrides of explicitly-defined 'dynamic' methods altogether, but in this case, the method was implicitly 'dynamic' because it was imported. Since a customer is hitting this issue with a snapshot toolchain, I'd like to check this in as-is. If you feel that perfecting the semantics is more important than the other items on your plate right now, you're welcome to take over. |
@swift-ci Please test Linux |
Given that there's a workaround—remove |
Having a workaround is not a good enough reason not to fix a crash. Users don't always know what the workaround is. |
Personally, I think avoiding the crash here is the right thing to do for 4.0. LGTM for 4.0 |
Description: Fixes an assertion failure when overriding an imported method (or property) with a final method (or property).
Scope of the issue: Affects builds with assertions on, like downloadable snapshots.
Origination: The underlying bug has been there forever I think, but became easier to hit when overrides of imported methods started to be marked 'dynamic' as part of the Swift 3/4 mix-and-match support.
Risk: Low. The change has been in the master branch for a while now with no apparent fallout.
Tested: New tests added.
Reviewed by: @jrose-apple