Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closure with multiple parameters compilation error #1353

Open
SeRG1k17 opened this issue Jul 24, 2024 · 0 comments
Open

Closure with multiple parameters compilation error #1353

SeRG1k17 opened this issue Jul 24, 2024 · 0 comments

Comments

@SeRG1k17
Copy link

SeRG1k17 commented Jul 24, 2024

// sourcery: AutoMockable
public protocol TestProtocol {

    func method(value: String, handler: ((Error, String) -> Void)?) -> Int
}

Mock:

public class TestProtocolMock: TestProtocol {

    public init() {}



    //MARK: - method

    public var methodValueStringHandlerErrorStringVoidIntCallsCount = 0
    public var methodValueStringHandlerErrorStringVoidIntCalled: Bool {
        return methodValueStringHandlerErrorStringVoidIntCallsCount > 0
    }
    public var methodValueStringHandlerErrorStringVoidIntReturnValue: Int!
    public var methodValueStringHandlerErrorStringVoidIntClosure: ((String, ((Error, String) -> Void)?) -> Int)?

// Extra Bracket here
    public func method(value: String, handler: (((Error, String) -> Void)?) -> Int {
        methodValueStringHandlerErrorStringVoidIntCallsCount += 1
        if let methodValueStringHandlerErrorStringVoidIntClosure = methodValueStringHandlerErrorStringVoidIntClosure {
            return methodValueStringHandlerErrorStringVoidIntClosure(value, handler)
        } else {
            return methodValueStringHandlerErrorStringVoidIntReturnValue
        }
    }


}

As you can see Sourcery added one bracket "(" in closure. This bug is reproducible only with multiple closure parameters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant