Open swift-ci opened 5 years ago
Interestingly enough, swapping the decls makes Swift call the factory method, e.g
@interface SCNObject : NSObject
- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)object;
@end
Comment by Luca Torella (JIRA)
Wow, I didn't notice that 🙂
Hmph, I thought we fixed this. Thanks, Luca.
Attachment: Download
Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, ClangImporter | |Assignee | None | |Priority | Medium | md5: 36bc2e8ec7bacc7ccce7f21da3dc15a7Issue Description:
If I have an Objective-C class where I have an
init
method marked asNS_UNAVAILABLE
and a factory method with no arguments and if I try to call that factory method from Swift, then the init method is invoked instead.Steps to Reproduce:
Create the following Objective-C class:
From Swift do:
It's easy to check with the debugger that the
init
method is called instead of the factory method.If I remove the factory method, then the code won't compile and the proper error message is displayed: "'init()' is unavailable"