Skip to content

Commit 5e8cf93

Browse files
committed
[ConstraintSystem] InferSendableFromCaptures: Mark unapplied operator references as @Sendable
Operator references don't have a base type and could be found via unqualified lookup, `adjustFunctionTypeForConcurrency` should handle them specifically. Resolves: rdar://131321053
1 parent 88e2484 commit 5e8cf93

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/Sema/ConstraintSystem.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,11 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
17751775
adjustedTy->withExtInfo(adjustedTy->getExtInfo().withSendable());
17761776
}
17771777
} else if (isPartialApplication(getConstraintLocator(locator))) {
1778-
if (baseType &&
1779-
(baseType->is<AnyMetatypeType>() || baseType->isSendableType())) {
1778+
// Operators on protocols could be found via unqualified lookup and
1779+
// won't have a base type.
1780+
if (decl->isOperator() ||
1781+
(baseType &&
1782+
(baseType->is<AnyMetatypeType>() || baseType->isSendableType()))) {
17801783
auto referenceTy = adjustedTy->getResult()->castTo<FunctionType>();
17811784
referenceTy =
17821785
referenceTy->withExtInfo(referenceTy->getExtInfo().withSendable())

test/Concurrency/sendable_methods.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,3 +286,11 @@ func testPatternMatch(ge: [GenericE<Int>]) {
286286
_ = a
287287
}
288288
}
289+
290+
// rdar://131321053 - cannot pass an operator to parameter that expectes a @Sendable type
291+
do {
292+
func test(_: @Sendable (Int, Int) -> Bool) {
293+
}
294+
295+
test(<) // Ok
296+
}

0 commit comments

Comments
 (0)