Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/Sema/TypeCheckConcurrency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2982,6 +2982,12 @@ namespace {
->mapTypeIntoContext(decl->getInterfaceType())
->getReferenceStorageReferent();

// Pack expansions are okay to capture as long as the pattern
// type is Sendable.
if (auto *expansion = type->getAs<PackExpansionType>()) {
type = expansion->getPatternType();
}

if (type->hasError())
continue;

Expand Down
20 changes: 20 additions & 0 deletions test/Concurrency/sendable_checking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,3 +507,23 @@ func checkOpaqueType() -> some Sendable {
class MainActorSub: MainActorSuper<MainActorSub.Nested> {
struct Nested {} // no cycle
}

@available(SwiftStdlib 5.9, *)
struct SendablePack<each Element: Sendable>: Sendable {
let elements: (repeat each Element)
}

@available(SwiftStdlib 5.1, *)
@MainActor
func sendablePacks<each Element: Sendable>(
_ element: repeat each Element
) async {
{ @Sendable in
repeat _ = each element
}()

await sendPack(repeat each element)
}

@available(SwiftStdlib 5.1, *)
func sendPack<each Element>(_: repeat each Element) async {}