Wrong IDE compiler quick fix suggestion
Originator: | vpeltwillem | ||
Number: | rdar://28979720 | Date Originated: | 27/11/2016 |
Status: | Open | Resolved: | |
Product: | Xcode | Product Version: | Version 8.1 (8T61a) |
Classification: | serious bug | Reproducible: | yes |
Summary: The Objective C protocol contains a function with a ResultBlock. Xcode suggests to conform to the protocol by implementing the function as follows: public func withCompletion(_ completion: ResultBlock) {} Afterwards it keeps on telling: Type ‘SynchronizationSwift’ does not conform to protocol ‘ObjectiveCProtocol’ And it suggests to implement the function again as stated above. I can get rid of the compilation error when adding a ? or ! as follows: public func withCompletion(_ completion: ResultBlock?) {} But this gives me a warning: Parameter of ‘withCompletion’ has different optionality than expected by protocol ‘ObjectiveCProtocol’ Steps to Reproduce: 1. Open the attached project in Xcode 2. Build the code Expected Results: Expected to suggest correct protocol implementation Actual Results: Incorrect suggestion that results in the same compilation error that we are trying the fix Version: Version 8.1 (8T61a) CODE ON GITHUB: https://github.com/wvpelt/xcode-compilation-issue
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Xcode doesn't give a warning nor error when the implementation adds the escaping attribute:
public func withCompletion(_ completion: @escaping ResultBlock) {}