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
[SR-7301] Bad fixit suggested for protocol extension implementation for inherited objc protocol #49849
Comments
Comment by Kaden Wilkinson (JIRA) Also get the same fixits using Xcode 9.3 beta 4 |
Yep, this just isn't possible, and we shouldn't offer the fix-it. (It's not possible because Objective-C doesn't have a way to add a method to every adopter of a protocol.) |
Comment by Tapan Thaker (JIRA) Taking this up |
Comment by Tapan Thaker (JIRA) The above code compiles fine on `Apple Swift version 4.1` from Xcode 9.3. Not sure what changed the behaviour. |
I think Swift 4.1 just ignored the extension method, rather than complaining that it was a near-match. The intended change here is that the note and fix-it are not offered if the method is defined on a protocol extension. |
Comment by Tapan Thaker (JIRA) The compilation also fails on Swift 4.1 as soon as we make a ViewController conform to a protocol. class CustomViewController: UIViewController, IntroAnimationController {
func frame(for view: UIView, fromView: UIView) -> CGRect { return CGRect(x: 0, y: 0, width: 0, height: 0) }
func animations(fromView: UIView, toView: UIView) -> () -> Void {
let x : () -> Void = {
}
return x
}
public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {}
} I think all we need to do is delete the following: |
In that case the fix-it is correct, no? |
Comment by Tapan Thaker (JIRA) No, the fix-it doesn't seem to be correct. Once you apply the fix-it, you get into the same problem of 2 new errors A simpler code snippet for reproducing the issue: import Foundation
@objc protocol Print {
func log(message string: NSString)
}
extension Print {
func log(message string: NSString) {
print(string)
}
}
class CustomClass: NSObject, Print { } |
It's totally fine for an |
Comment by Suyash Shekhar (JIRA) tt (JIRA User) Are you still working on this? If not I would like to give it a shot 🙂 |
Resetting assignee for all Starter Bugs not modified since 2018. |
Attachment: Download
Environment
Xcode 9.2
Swift 4
macOS 10.13.3
Additional Detail from JIRA
md5: f483fe309b1876278257725a1dc2b1b5
relates to:
Issue Description:
I have the following code that has a compiler error
The error says:
![](Screen Shot 2018-03-28 at 3.47.33 PM.png)
and includes a fixit that that turns my code into this:
And then gives me these two wonderful new errors:
![](Screen Shot 2018-03-28 at 3.46.32 PM.png)
None of the fixits are helpful and the error message does not give me any clue why I can't do this
The text was updated successfully, but these errors were encountered: