Skip to content
This repository was archived by the owner on Jul 3, 2022. It is now read-only.
This repository was archived by the owner on Jul 3, 2022. It is now read-only.

Cannot return a future with a different error type by chaining calls with flatMap #115

@NickAger

Description

@NickAger

To illustrate the problem I've modified one of the methods in the test suite, substituting NSError for NoError

    func testFlatMapByPassingFunction() {
        let e = self.expectation()

        func toString(n: Int) -> Future<String, NSError> {
            return Future<String, NSError>(value: "\(n)")
        }

        let n = 1
        let flatMapped = Future<Int, NoError>(value: n).flatMap(toString)

        flatMapped.onSuccess { s in
            XCTAssertEqual(s, "\(n)", "strings are not equal")
            e.fulfill()
        }

        self.waitForExpectationsWithTimeout(2, handler: nil)
    }

Which result in the error: Cannot invoke 'flatMap' with an argument list of type '((Int) -> Future<String, NSError>)'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions