-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Stub fix-its for missing objcImpl requirements #80476
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@swift-ci please test |
tshortli
approved these changes
Apr 2, 2025
Hmm. The |
@swift-ci please test |
Changes the diagnostics emitted when an `@objc @implementation` extension is missing some of the members required by the extension: • We now emit one error on the extension, plus a note for each missing member. • Where possible, we also emit a note with a fix-it adding stubs. For example: ``` 9 | @objc @implementation extension ObjCClass { | |- error: extension for main class interface does not provide all required implementations | |- note: missing instance method 'method(fromHeader3:)' | |- note: missing instance method 'method(fromHeader4:)' | |- note: missing property 'propertyFromHeader7' | |- note: missing property 'propertyFromHeader8' | |- note: missing property 'propertyFromHeader9' | |- note: missing instance method 'extensionMethod(fromHeader2:)' | `- note: add stubs for missing '@implementation' requirements ``` With a fix-it on the last note to insert the following after the open brace: ``` @objc(methodFromHeader3:) open func method(fromHeader3 param: Int32) { <#code#> } @objc(methodFromHeader4:) open func method(fromHeader4 param: Int32) { <#code#> } @objc(propertyFromHeader7) open var propertyFromHeader7: Int32 { get { <#code#> } set { <#code#> } } @objc(propertyFromHeader8) open var propertyFromHeader8: Int32 { get { <#code#> } set { <#code#> } } @objc(propertyFromHeader9) open var propertyFromHeader9: Int32 { get { <#code#> } set { <#code#> } } @objc(extensionMethodFromHeader2:) open func extensionMethod(fromHeader2 param: Int32) { <#code#> } ``` Fixes rdar://130038221.
@swift-ci please test |
When generating a stub fix-it for a protocol conformance or implementation extension, Swift will now evaluate whether the context allows the declaration of stored properties and, if so, will suggest one. It will also use the `let` keyword instead of `var` if the property has no setter.
The diagnostic mentions both possible names, but only provides a stub for the `async` variant.
@swift-ci please test |
xymus
reviewed
Apr 10, 2025
xymus
approved these changes
Apr 10, 2025
🙏Thank you for adding this, Becca! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes the diagnostics emitted when an
@objc @implementation
extension is missing some of the members required by the extension:For example:
With a fix-it on the last note to insert the following after the open brace:
Fixes rdar://130038221.