Closed fummicc1 closed 1 year ago
When we try to create a protocol that has method like below,
public protocol Foo {} public struct Bar: Foo {} // NG /// @mockable public protocol Controller { func method(foo: some Foo) -> Int }
Output mock fails to compile like this.
The reason is some keyword can't be used at the parameter of closure if the closure is placed at return type.
some
public var methodHandler: ((some Foo) -> (Int))? // compile error happens
We can avoid this case by using <F: Foo> generics parameter instead of some keyword.
<F: Foo>
public protocol Foo {} public struct Bar: Foo {} // OK /// @mockable public protocol Controller { func method<F: Foo>(foo: F) -> Int }
but I think it is valuable to investigate if it can be fixed or not.
Problem
When we try to create a protocol that has method like below,
Output mock fails to compile like this.
Reason & Workaround
The reason is
some
keyword can't be used at the parameter of closure if the closure is placed at return type.We can avoid this case by using
<F: Foo>
generics parameter instead ofsome
keyword.but I think it is valuable to investigate if it can be fixed or not.
Sample to reproduce