Skip to content

[4.1] Suggest @objc for overrides of declarations from/in extensions. #13420

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

Conversation

DougGregor
Copy link
Member

  • Explanation: Customize the "cannot override declaration in extension" diagnostic to
    suggest adding @objc to the overridden declaration in cases where
    @objc is permitted, nudging users toward a simpler solution than refactoring their code extensively.
  • Scope of Issue: Helps users, particularly when migrating from Swift 3 to Swift 4 (due to SE-0160).
  • Risk: Very low; it's a diagnostic change.
  • Reviewed By: @jckarter
  • Testing: Existing automated test suite, new tests
  • Directions for QA: N/A
  • SR / Radar: SR-6512 / rdar://problem/35787914

The Swift class model does not support overriding declarations where either
the overridden declaration or the overriding declaration are in an extension.
However, the Objective-C class model does, so marking the declaration as
@objc (when possible) will work around the limitation.

Customize the "cannot override declaration in extension" diagnostic to
suggest adding @objc to the overridden declaration in cases where
@objc is permitted. Fixes SR-6512 / rdar://problem/35787914.

(cherry picked from commit cabdf84)
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor
Copy link
Member Author

@swift-ci please nominate

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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