Skip to content

Commit ff60ee5

Browse files
committed
[sending] Teach sending how to suppress sending from functions passed to inits.
rdar://129045783 (cherry picked from commit 11f86a5)
1 parent 140fcf3 commit ff60ee5

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/AST/FeatureSet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static bool usesFeatureSendingArgsAndResults(Decl *decl) {
669669
return true;
670670
}
671671

672-
if (auto *fDecl = dyn_cast<FuncDecl>(decl)) {
672+
if (auto *fDecl = dyn_cast<AbstractFunctionDecl>(decl)) {
673673
// First check for param decl results.
674674
if (llvm::any_of(fDecl->getParameters()->getArray(), [](ParamDecl *pd) {
675675
return usesFeatureSendingArgsAndResults(pd);

test/Concurrency/sending_conditional_suppression.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ public struct TestInStruct {
9595
// CHECK-NEXT: public func testFunctionArg(_ x: () -> sending test.NonSendableKlass)
9696
// CHECK-NEXT: #else
9797
// CHECK-NEXT: public func testFunctionArg(_ x: () -> test.NonSendableKlass)
98-
// CHECK-NEXT: #endif
98+
// CHECK-NEXT: #endif
9999
public func testFunctionArg(_ x: () -> sending NonSendableKlass) { fatalError() }
100100

101101
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
102102
// CHECK-NEXT: public func testFunctionResult() -> (() -> sending test.NonSendableKlass)
103103
// CHECK-NEXT: #else
104104
// CHECK-NEXT: public func testFunctionResult() -> (() -> test.NonSendableKlass)
105-
// CHECK-NEXT: #endif
105+
// CHECK-NEXT: #endif
106106
public func testFunctionResult() -> (() -> sending NonSendableKlass) { fatalError() }
107107

108108
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
@@ -187,6 +187,16 @@ public struct TestInStruct {
187187
// CHECK-NEXT: #endif
188188
@usableFromInline
189189
let internalLetFieldFunctionArg: (sending NonSendableKlass) -> ()
190+
191+
// CHECK-LABEL: #if compiler(>=5.3) && $SendingArgsAndResults
192+
// CHECK-NEXT: @usableFromInline
193+
// CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending test.NonSendableKlass) { fatalError() }
194+
// CHECK-NEXT: #else
195+
// CHECK-NEXT: @usableFromInline
196+
// CHECK-NEXT: internal init(_ x: Int, transformWithResult: @escaping () async throws -> test.NonSendableKlass) { fatalError() }
197+
// CHECK-NEXT: #endif
198+
@usableFromInline
199+
internal init(_ x: Int, transformWithResult: @escaping () async throws -> sending NonSendableKlass) { fatalError() }
190200
}
191201

192202
// Make sure that we emit compiler(>= 5.3) when emitting the suppressing check

0 commit comments

Comments
 (0)