Skip to content

Typechecking timeout compiling tests in v7 #1026

Open
@GarthSnyder

Description

@GarthSnyder

With the cancellation code merged into v7, my hamster-wheel-powered Mac Mini is timing out while compiling Tests/Cancel/DispatcherTests.swift -> testMapValues().

    func testMapValues() {
        let ex1 = expectation(description: "DispatchQueue MapValues compatibility")
        Promise.value([42, 52]).cancellize().then(on: .global(qos: .background), flags: .barrier) { v -> Promise<[Int]> in
            Promise.value(v)
        }.compactMap(on: .global(qos: .background), flags: .barrier) {
            $0
        }.mapValues(on: .global(qos: .background), flags: .barrier) {
            $0 + 10
        }.flatMapValues(on: .global(qos: .background), flags: .barrier) {
            [$0 + 10]
        }.compactMapValues(on: .global(qos: .background), flags: .barrier) {
            $0 + 10
        }.thenMap(on: .global(qos: .background), flags: .barrier) { v -> CancellablePromise<Int> in
            Promise.value(v + 10).cancellize()
        }.thenMap(on: .global(qos: .background), flags: .barrier) { v -> Promise<Int> in
            Promise.value(v + 10)
        }.thenFlatMap(on: .global(qos: .background), flags: .barrier) {
            Promise.value([$0 + 10]).cancellize()
        }.thenFlatMap(on: .global(qos: .background), flags: .barrier) { v -> Promise<[Int]> in
            Promise.value([v + 10])
        }.filterValues(on: .global(qos: .background), flags: .barrier) { _ in
            true
        }.sortedValues(on: .global(qos: .background), flags: .barrier).firstValue(on: .global(qos: .background), flags: .barrier) { _ in
            true
        }.done(on: .global(qos: .background), flags: .barrier) {
            XCTAssertEqual($0, 112)
            ex1.fulfill()
        }.catch(on: .global(qos: .background), flags: .barrier) { _ in
            XCTFail()
        }

The error is the usual "The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions".

This is a pretty complicated expression to resolve (259 separate type decisions, according to swift -debug-constraints), but I'm a bit suspicious that the complexity may derive from the use of cancellable promises. If you edit out the calls to cancellize(), it compiles fine.

@dougzilla32, is there some reason why cancellable promises might have a broader API than regular promises?

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