Skip to content

Allow overrides in @_objcImplementation extensions #61782

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
merged 3 commits into from
Oct 28, 2022

Conversation

beccadax
Copy link
Contributor

This PR contains a small suite of changes that allow superclass methods, properties, and initializers to be overridden in @_objcImplementation extensions. Overrides do not have to be declared in the @interface.

Follow-up to #60630; additional work on rdar://70730077.

Treating this as forbidden was incorrect; an `@objc final` method is simply one that isn’t a member implementation but does have an ObjC entry point.

Formalize and centralize the definition of what a member implementation is, tweak it so that it’s basically “non-final and internal or greater”, and permit `@objc final`. Also remove the inference of `final` on `let`s in @_objcImpl extensions.
Without this change, an `@_objcImplementation` cannot override parent class methods, because the special access control behavior breaks the access control checks for overrides.
Previously, Swift would reject an `override public init(…)` in an `@_objcImplementation` because ClangImporter would have already synthesized inherited initializers that conflicted with the overrides. Ignore these spurious conflicts, and also move a check out of IsObjCRequest and into the conflict-handling code.

Additional work towards rdar://70730077.
@beccadax beccadax force-pushed the at-implementation-2 branch from 825fb87 to 3e4ea43 Compare October 28, 2022 00:00
@beccadax
Copy link
Contributor Author

@swift-ci smoke test

@beccadax beccadax requested a review from DougGregor October 28, 2022 00:02
@beccadax beccadax merged commit e79aefa into swiftlang:main Oct 28, 2022
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.

2 participants