skiptools / skiptools/skip-lib
withThrowingTaskGroup(of:returning:isolation:body:) transpiled incorrectly
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 13
- Forks
- 4
- Avg merge
- 1h 49m
- Merged PRs (30d)
- 2
Description
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.
Proposed solution:
I think this:
withThrowingTaskGroup(of = Array::class)
needs to change to this:
withThrowingTaskGroup(of = Array<FNCProduct>::class)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue with the Swift withThrowingTaskGroup(of:returning:isolation:body:) example and inspect the generated Kotlin call using Array::class. The fix is complete when the generated type preserves FNCProduct and the append(contentsOf:) line compiles without the reported type mismatch.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin, swift
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100