Skip to content

Commit 3ae8d56

Browse files
committed
[CSFix] Fix getConcurrencyFixBehavior to account for non-decl overloads
Adjust the downgrade check for static member references to account for the fact that argument could come of a tuple or some other reference that doesn't have a declaration associated with it. Resolves: rdar://153083848
1 parent 0999792 commit 3ae8d56

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Sema/CSFix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ getConcurrencyFixBehavior(ConstraintSystem &cs, ConstraintKind constraintKind,
300300
if (auto *argument = getAsExpr(simplifyLocatorToAnchor(argLoc))) {
301301
if (auto overload = cs.findSelectedOverloadFor(
302302
argument->getSemanticsProvidingExpr())) {
303-
auto *decl = overload->choice.getDecl();
303+
auto *decl = overload->choice.getDeclOrNull();
304304
if (decl && decl->isStatic())
305305
return FixBehavior::DowngradeToWarning;
306306
}

test/Concurrency/sendable_checking.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,3 +526,11 @@ func sendablePacks<each Element: Sendable>(
526526

527527
@available(SwiftStdlib 5.1, *)
528528
func sendPack<each Element>(_: repeat each Element) async {}
529+
530+
// rdar://153083848 - crash in `getConcurrencyFixBehavior` when member comes from a tuple
531+
func test(value: (_: Int, _: () -> Void)) {
532+
func takesSendable(_: @Sendable () -> Void) {}
533+
534+
takesSendable(value.1) // Ok
535+
// expected-warning@-1 {{converting non-Sendable function value to '@Sendable () -> Void' may introduce data races}}
536+
}

0 commit comments

Comments
 (0)