Skip to content

Commit f2477e4

Browse files
committed
Don't apply @Sendable to enum cases in pattern matching
1 parent 9f257e4 commit f2477e4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1714,7 +1714,8 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
17141714
if (auto *FD = dyn_cast<AbstractFunctionDecl>(decl)) {
17151715
DC = FD->getDeclContext();
17161716
} else if (auto EED = dyn_cast<EnumElementDecl>(decl)) {
1717-
if (EED->hasAssociatedValues()) {
1717+
if (EED->hasAssociatedValues() &&
1718+
!locator.endsWith<LocatorPathElt::PatternMatch>()) {
17181719
DC = EED->getDeclContext();
17191720
}
17201721
}

test/Concurrency/sendable_methods.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,3 +279,10 @@ func acceptSendableFunc<T, U>(_: @Sendable (T) -> U) { }
279279
acceptSendableFunc(InferredSendableE.c)
280280
acceptSendableFunc(GenericE<Int>.b)
281281
acceptSendableFunc(GenericE<NonSendable>.b)
282+
283+
// Make sure pattern matching isn't affected by @Sendable on cases.
284+
func testPatternMatch(ge: [GenericE<Int>]) {
285+
if case .b(let a) = ge.first {
286+
_ = a
287+
}
288+
}

0 commit comments

Comments
 (0)