File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -46,3 +46,17 @@ func testAsync() async {
46
46
}
47
47
mutableVariable += 1
48
48
}
49
+
50
+ // rdar://99518344 - @Sendable in nested positions
51
+ @preconcurrency typealias OtherHandler = @Sendable ( ) -> Void
52
+ @preconcurrency typealias Handler = ( @Sendable ( ) -> OtherHandler ? ) ?
53
+ @preconcurrency func f( arg: Int , withFn: Handler ? ) { }
54
+
55
+ class C {
56
+ func test( ) {
57
+ f ( arg: 5 , withFn: { [ weak self] ( ) -> OtherHandler ? in
58
+ _ = self
59
+ return nil
60
+ } )
61
+ }
62
+ }
Original file line number Diff line number Diff line change 2
2
// REQUIRES: concurrency
3
3
4
4
// Concurrent attribute on a function type.
5
+ // expected-note@+1{{found this candidate}}
5
6
func f( _ fn: @Sendable ( Int ) -> Int ) { }
6
7
7
8
// Okay to overload @Sendable vs. not concurrent
9
+ // expected-note@+1{{found this candidate}}
8
10
func f( _ fn: ( Int ) -> Int ) { }
9
11
10
12
// Concurrent attribute with other function attributes.
@@ -24,8 +26,10 @@ func passingConcurrentOrNot(
24
26
_ cfn: @Sendable ( Int ) -> Int ,
25
27
ncfn: ( Int ) -> Int // expected-note{{parameter 'ncfn' is implicitly non-sendable}}{{9-9=@Sendable }}
26
28
) {
29
+ // Ambiguous because preconcurrency code doesn't consider `@Sendable`.
30
+ f ( cfn) // expected-error{{ambiguous use of 'f'}}
31
+
27
32
// Okay due to overloading
28
- f ( cfn)
29
33
f ( ncfn)
30
34
31
35
acceptsConcurrent ( cfn) // okay
You can’t perform that action at this time.
0 commit comments