Skip to content

withThrowingTaskGroup(of:returning:isolation:body:) transpiled incorrectly #24

@vdkdamian

Description

@vdkdamian

Issue

I have a function with the following Swift code:

var allProducts: [FNCProduct] = []

try await withThrowingTaskGroup(of: [FNCProduct].self) { pageProductsTaskGroup in
    // Some irrelevant code

    for try await pageProducts in pageProductsTaskGroup {
        allProducts.append(contentsOf: pageProducts)
    }
}

return allProducts

This gets transpiled to the following Kotlin code:

var allProducts: Array<FNCProduct> = arrayOf()

withThrowingTaskGroup(of = Array::class) { pageProductsTaskGroup ->
    // Some irrelevant code

    for (pageProducts in pageProductsTaskGroup.sref()) {
        allProducts.append(contentsOf = pageProducts)
    }
}

return@l allProducts.sref()

I'm getting an error from the compiler that refers to the following line:
allProducts.append(contentsOf = pageProducts)

Argument type mismatch: actual type is 'skip.lib.Array<CapturedType(*)>', but 'skip.lib.Sequence<funico.module.FNCProduct>' was expected.

Issue

Proposed solution:

I think this:

withThrowingTaskGroup(of = Array::class)

needs to change to this:

withThrowingTaskGroup(of = Array<FNCProduct>::class)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions