A mock file will fail to compile if the protocol being mocked contains two functions with the same signature and name but has different generic constraints. Consider the following example:
@CreateMock
protocol Foo {
func connect<T>(adapter: T) where T: Adapter
func connect<T>(adapter: T) where T: KeyedAdapter
}
The above code will generate the following mock:
public var connectCallCount = 0
public var connectHandler: ((Any) -> ())?
public func connect<T>(adapter: T) where T: Adapter {
mockFunc(&connectCallCount)("connect", connectHandler?(adapter), .void)
}
This fails to compile because it's missing the implementation with KeyedAdapter. With this PR, the following mock will now be produced
public var connectCallCount = 0
public var connectHandler: ((Any) -> ())?
public func connect<T>(adapter: T) where T: EntityAdapter {
mockFunc(&connectCallCount)("connect", connectHandler?(adapter), .void)
}
public var connectAdapterCallCount =0
public var connectAdapterHandler: ((Any) -> ())?
public func connect<T>(adapter: T) where T: KeyedEntityAdapter {
mockFunc(&connectAdapterCallCount)("connect", connectAdapterHandler?(adapter), .void)
}
A mock file will fail to compile if the protocol being mocked contains two functions with the same signature and name but has different generic constraints. Consider the following example:
The above code will generate the following mock:
This fails to compile because it's missing the implementation with
KeyedAdapter
. With this PR, the following mock will now be produced