File tree 3 files changed +58
-2
lines changed
3 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -2924,8 +2924,10 @@ namespace {
2924
2924
auto *explicitClosure = dyn_cast_or_null<ClosureExpr>(closure);
2925
2925
2926
2926
bool preconcurrency = false ;
2927
- if (explicitClosure) {
2928
- preconcurrency = explicitClosure->isIsolatedByPreconcurrency ();
2927
+ if (closure) {
2928
+ preconcurrency =
2929
+ getActorIsolationOfContext (closure, getClosureActorIsolation)
2930
+ .preconcurrency ();
2929
2931
}
2930
2932
2931
2933
for (const auto &capture : localFunc.getCaptureInfo ().getCaptures ()) {
Original file line number Diff line number Diff line change 50
50
}
51
51
}
52
52
}
53
+
54
+ func use( _ closure: @autoclosure ( ) -> Any ) {
55
+ }
56
+
57
+ do {
58
+ class C {
59
+ @preconcurrency static func f( _: @escaping @Sendable ( ) -> Void ) { }
60
+ }
61
+
62
+ class SelfCapture { // expected-note 5 {{class 'SelfCapture' does not conform to the 'Sendable' protocol}}
63
+ func fooDirect( ) {
64
+ C . f {
65
+ use ( self )
66
+ // expected-warning@-1 {{capture of 'self' with non-sendable type 'SelfCapture' in a '@Sendable' closure}}
67
+ // expected-warning@-2 {{implicit capture of 'self' requires that 'SelfCapture' conforms to 'Sendable'}}
68
+ }
69
+ }
70
+
71
+ func fooThroughClosure( ) {
72
+ C . f {
73
+ { use ( self ) } ( )
74
+ // expected-warning@-1 {{capture of 'self' with non-sendable type 'SelfCapture' in a '@Sendable' closure}}
75
+ // expected-warning@-2 {{capture of 'self' with non-sendable type 'SelfCapture' in an isolated closure}}
76
+ // expected-warning@-3 {{implicit capture of 'self' requires that 'SelfCapture' conforms to 'Sendable'}}
77
+ }
78
+ }
79
+ }
80
+ }
Original file line number Diff line number Diff line change @@ -86,6 +86,10 @@ void doSomethingConcurrently(__attribute__((noescape)) void SWIFT_SENDABLE (^blo
86
86
- ( void) testWithComplet ion: ( void ( ^) ( void) ) completion;
87
87
@end
88
88
89
+ @interface TestSelfCapture : NSObject
90
+ + ( void) do WithComplet ion : ( void ( ^) ( void ) ) complet ion;
91
+ @end
92
+
89
93
#pragma clang assume_nonnull end
90
94
91
95
//--- main.swift
@@ -219,3 +223,25 @@ extension TestDR {
219
223
@_dynamicReplacement ( for: test ( completion: ) )
220
224
func __replaceObjCFunc( _: @escaping ( ) -> Void ) { } // Ok
221
225
}
226
+
227
+ class SelfCapture { // expected-note 5 {{class 'SelfCapture' does not conform to the 'Sendable' protocol}}
228
+ static func use( _ closure: @autoclosure ( ) -> Any ) {
229
+ }
230
+
231
+ func testDirect( ) {
232
+ TestSelfCapture . do {
233
+ Self . use ( self )
234
+ // expected-warning@-1 {{capture of 'self' with non-sendable type 'SelfCapture' in a '@Sendable' closure}}
235
+ // expected-warning@-2 {{implicit capture of 'self' requires that 'SelfCapture' conforms to 'Sendable'}}
236
+ }
237
+ }
238
+
239
+ func testThroughClosure( ) {
240
+ TestSelfCapture . do {
241
+ let _ = { Self . use ( self ) } ( )
242
+ // expected-warning@-1 {{capture of 'self' with non-sendable type 'SelfCapture' in a '@Sendable' closure}}
243
+ // expected-warning@-2 {{capture of 'self' with non-sendable type 'SelfCapture' in an isolated closure}}
244
+ // expected-warning@-3 {{implicit capture of 'self' requires that 'SelfCapture' conforms to 'Sendable'}}
245
+ }
246
+ }
247
+ }
You can’t perform that action at this time.
0 commit comments