forked from typealiased/mockingbird
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix optional members in Obj-C protocols (typealiased#279)
## Overview Generating Swift mocks for Objective-C annotated protocols with optional members regressed in 0.18 due to invocation forwarding for partial mocks. This PR allows the generator to explicitly handle optional members and improves the overall Objective-C compatibility. ## Test Plan Added an additional test case for Objective-C protocols.
- Loading branch information
1 parent
5e44556
commit 20ad1c6
Showing
14 changed files
with
298 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
4 changes: 4 additions & 0 deletions
4
Mockingbird.xcodeproj/xcconfigs/MockingbirdGenerator.xcconfig
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
#include "FrameworkBase.xcconfig" | ||
|
||
// Identifiers | ||
INFOPLIST_FILE = $(SRCROOT)/Sources/MockingbirdGenerator/Info.plist | ||
SUPPORTED_PLATFORMS = macosx | ||
PRODUCT_MODULE_NAME = MockingbirdGenerator | ||
PRODUCT_NAME = MockingbirdGenerator | ||
TARGET_NAME = MockingbirdGenerator | ||
|
||
// Compatibility | ||
MACOSX_DEPLOYMENT_TARGET = 10.15 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Foundation | ||
|
||
@objc protocol ObjCProtocol: Foundation.NSObjectProtocol { | ||
@objc func trivial() | ||
@objc func parameterizedReturning(param: String) -> Bool | ||
|
||
@objc var property: Bool { get } | ||
@objc var readwriteProperty: Bool { get set } | ||
|
||
// It’s possible to define Obj-C protocols with overloaded subscript requirements, but it can | ||
// never be implemented in Swift as the compiler will complain about the conflicting selectors. | ||
// @objc subscript(param: Int) -> Int { get set } | ||
|
||
// MARK: Optional | ||
|
||
@objc optional func optionalTrivial() | ||
@objc optional func optionalParameterizedReturning(param: String) -> Bool | ||
|
||
@objc optional var optionalProperty: Bool { get } | ||
@objc optional var optionalReadwriteProperty: Bool { get set } | ||
|
||
@objc optional subscript(param: Int) -> Bool { get set } | ||
} |
Oops, something went wrong.