[SR-9556] Swift Class Conforming to ObjC Protocol Mixes Up Methods That Take a Block and Throw #52004
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
PrintAsClang
Area → compiler: The PrintAsClang library
Additional Detail from JIRA
md5: be31b506c5609f3b4bd9f08507f8c863
Issue Description:
When a Swift class conforms to an Objective-C protocol that has a method that is both passed a block and “throws” (BOOL and NSError out pointer), the types on that method’s parameter list go out of order. For instance, the method:
- (BOOL) testBlock: (BOOL (^)(void))block error: (NSError**)error;
is turned into (from the Swift generated header):
- (BOOL)testBlock:(NSError * _Nullable * _Nullable)error error:(BOOL (^ _Nonnull)(void))block;
Results:
When importing Swift generated headers into Obj-C, calling the method on a variable of the class type will result in a compiler error. Calling the method on a variable of the protocol type will crash at runtime.
The text was updated successfully, but these errors were encountered: