-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add @implementation and feature flags for objcImpl #72596
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
Conversation
With swiftlang/swift-syntax#2570 @swift-ci please test |
With swiftlang/swift-syntax#2570 @swift-ci please test |
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.
LGTM! I left one suggestion for diagnostic wording.
They will eventually have slightly different deprecation status and error behavior, but not yet. Fixes rdar://110728033.
They will have slightly different enablement and diagnostic behavior in a future commit.
• ObjCImplementation controls @implementation on extensions • CImplementation controls @implementation and @_objcImplementation on cdecl functions Why the difference between them? Because `@_objcImplementation extension` has already been adopted pretty widely, while `@_objcImplementation @_cdecl` is very new.
…only when the ObjCImplementation experimental language feature is enabled. (`@implementation extension` is the preferred form.)
Adopting @implementation turns all of the warnings into errors.
Helps allow test/decl/ext/cdecl_implementation.swift to run on non-ObjC platforms.
3f18cea
to
0505c38
Compare
With swiftlang/swift-syntax#2570 @swift-ci please test |
|
||
// YES-DAG: cdecl_implementation_features.swift:[[@LINE+4]]:{{[0-9]+}}: warning: global function 'CImplFunc1' of type '(Double) -> ()' does not match type '(Int32) -> Void' declared by the header; this will become an error after adopting '@implementation' | ||
// NO-DAG: cdecl_implementation_features.swift:[[@LINE+3]]:{{[0-9]+}}: error: '_objcImplementation' attribute is only valid when experimental feature CImplementation is enabled | ||
// YES-NOT: cdecl_implementation_features.swift:[[@LINE+2]]:{{[0-9]+}}: warning: warning-only '@_objcImplementation' spelling is deprecated; use '@implementation' instead |
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.
This CHECK
line looks like it might be out of date
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.
Just noticed that myself. Good catch!
• Simpler wording • Now emitted only if there are no other @objcImpl diagnostics (so @implementation would not emit any new errors)
0505c38
to
858b557
Compare
With swiftlang/swift-syntax#2570 @swift-ci please test |
I will shortly be pushing changes that make the matching swift-syntax PR unnecessary. |
Rather than adding custom parsing to SwiftSyntax, we can parse this as a custom attribute and convert it to a built-in one in ASTGen. Test that this works correctly (and fix a bug where it wasn’t).
@swift-ci please test |
🎉 |
@swift-ci please test |
This PR makes a series of intertwined changes to
@_objcImplementation
:@implementation
, the public syntax I intend to propose@_objcImplementation
will continue to be supported for the time being; the old syntax will warn instead of error for checker diagnosticsObjCImplementation
experimental feature to gate access to@implementation extension
s@_objcImplementation
will cause a deprecation warningCImplementation
experimental feature to gate access to@implementation @_cdecl
and@_objcImplementation @_cdecl
To aid in reviewing, I'm delaying some very mechanical follow-up work until another PR:
ObjCImplementationAttr
toImplementationAttr
@_objcImplementation
to using@implementation
This PR will need a matching swift-syntax PR.
Fixes rdar://110728033.