14
14
// CHECK-NEXT: end_borrow [[FN_BORROW2]]
15
15
// CHECK-NEXT: end_borrow [[FN_BORROW1]]
16
16
// CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]]
17
- func callSync( fn: @isolated ( any) ( ) -> ( ) ) async {
17
+ func callSync( fn: @isolated ( any) @ Sendable ( ) -> ( ) ) async {
18
18
await fn ( )
19
19
}
20
20
@@ -26,7 +26,7 @@ func callSync(fn: @isolated(any) () -> ()) async {
26
26
// CHECK-NEXT: apply [[FN_BORROW2]]()
27
27
// CHECK-NEXT: end_borrow [[FN_BORROW2]]
28
28
// CHECK-NEXT: hop_to_executor [[NIL_EXECUTOR]]
29
- func callAsync( fn: @isolated ( any) ( ) async -> ( ) ) async {
29
+ func callAsync( fn: @isolated ( any) @ Sendable ( ) async -> ( ) ) async {
30
30
await fn ( )
31
31
}
32
32
@@ -40,7 +40,7 @@ func callAsync(fn: @isolated(any) () async -> ()) async {
40
40
// CHECK-NEXT: [[THUNKED_FN:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[THUNK]]([[ISOLATION]], [[FN_COPY]])
41
41
// CHECK-NEXT: return [[THUNKED_FN]] : $@isolated(any) @Sendable @async @callee_guaranteed () -> ()
42
42
func convertFromNonIsolated( fn: @escaping @Sendable ( ) async -> ( ) )
43
- -> @isolated ( any) ( ) async -> ( ) {
43
+ -> @isolated ( any) @ Sendable ( ) async -> ( ) {
44
44
return fn
45
45
}
46
46
@@ -71,7 +71,7 @@ func convertFromNonIsolated(fn: @escaping @Sendable () async -> ())
71
71
// CHECK-NEXT: [[THUNKED_FN:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[THUNK]]([[ISOLATION]], [[FN_COPY]])
72
72
// CHECK-NEXT: return [[THUNKED_FN]] : $@isolated(any) @Sendable @async @callee_guaranteed () -> ()
73
73
func convertFromMainActor( fn: @escaping @Sendable @MainActor ( ) async -> ( ) )
74
- -> @isolated ( any) ( ) async -> ( ) {
74
+ -> @isolated ( any) @ Sendable ( ) async -> ( ) {
75
75
return fn
76
76
}
77
77
@@ -90,7 +90,7 @@ func convertFromMainActor(fn: @escaping @Sendable @MainActor () async -> ())
90
90
// CHECK-NEXT: [[THUNKED_FN:%.*]] = partial_apply [callee_guaranteed] [isolated_any] [[THUNK]]([[ISOLATION]], [[FN_COPY]])
91
91
// CHECK-NEXT: return [[THUNKED_FN]] : $@isolated(any) @Sendable @async @callee_guaranteed () -> Optional<Int>
92
92
func convertFromMainActorWithOtherChanges( fn: @escaping @Sendable @MainActor ( ) async -> Int )
93
- -> @isolated ( any) ( ) async -> Int ? {
93
+ -> @isolated ( any) @ Sendable ( ) async -> Int ? {
94
94
return fn
95
95
}
96
96
@@ -107,7 +107,7 @@ func convertFromMainActorWithOtherChanges(fn: @escaping @Sendable @MainActor ()
107
107
// CHECK-NEXT: [[FN_COPY:%.*]] = copy_value %0 :
108
108
// CHECK-NEXT: [[FN_CONVERTED:%.*]] = convert_function [[FN_COPY]] : $@isolated(any) @Sendable @async @callee_guaranteed () -> () to $@Sendable @async @callee_guaranteed () -> ()
109
109
// CHECK-NEXT: return [[FN_CONVERTED]] :
110
- func convertToNonIsolated( fn: @escaping @isolated ( any) ( ) async -> ( ) )
110
+ func convertToNonIsolated( fn: @escaping @isolated ( any) @ Sendable ( ) async -> ( ) )
111
111
-> @Sendable ( ) async -> ( ) {
112
112
return fn
113
113
}
@@ -129,16 +129,16 @@ func convertToNonIsolated(fn: @escaping @isolated(any) () async -> ())
129
129
// CHECK-NEXT: [[SOME_INT:%.*]] = enum $Optional<Int>, #Optional.some!enumelt, [[INT]] : $Int
130
130
// CHECK-NEXT: return [[SOME_INT]] : $Optional<Int>
131
131
132
- func convertToNonIsolatedWithOtherChanges( fn: @escaping @isolated ( any) ( ) async -> Int ) -> @Sendable ( ) async -> Int ? {
132
+ func convertToNonIsolatedWithOtherChanges( fn: @escaping @isolated ( any) @ Sendable ( ) async -> Int ) -> @Sendable ( ) async -> Int ? {
133
133
return fn
134
134
}
135
135
136
136
/*-- Sync closures --*/
137
137
138
138
func syncAction( ) { }
139
139
140
- func takeSyncIsolatedAny( fn: @escaping @isolated ( any) ( ) -> ( ) ) { }
141
- func takeInheritingSyncIsolatedAny( @_inheritActorContext fn: @escaping @isolated ( any) ( ) -> ( ) ) { }
140
+ func takeSyncIsolatedAny( fn: @escaping @isolated ( any) @ Sendable ( ) -> ( ) ) { }
141
+ func takeInheritingSyncIsolatedAny( @_inheritActorContext fn: @escaping @isolated ( any) @ Sendable ( ) -> ( ) ) { }
142
142
143
143
// CHECK-LABEL: sil hidden [ossa] @$s4test0A27EraseSyncNonIsolatedClosureyyF
144
144
// CHECK: // function_ref closure #1
@@ -246,8 +246,8 @@ actor MyActor {
246
246
247
247
func asyncAction( ) async { }
248
248
249
- func takeAsyncIsolatedAny( fn: @escaping @isolated ( any) ( ) async -> ( ) ) { }
250
- func takeInheritingAsyncIsolatedAny( @_inheritActorContext fn: @escaping @isolated ( any) ( ) async -> ( ) ) { }
249
+ func takeAsyncIsolatedAny( fn: @escaping @isolated ( any) @ Sendable ( ) async -> ( ) ) { }
250
+ func takeInheritingAsyncIsolatedAny( @_inheritActorContext fn: @escaping @isolated ( any) @ Sendable ( ) async -> ( ) ) { }
251
251
252
252
// CHECK-LABEL: sil hidden [ossa] @$s4test0A28EraseAsyncNonIsolatedClosureyyF
253
253
// CHECK: // function_ref closure #1
@@ -383,7 +383,7 @@ extension MyActor {
383
383
func asyncAction( ) async { }
384
384
}
385
385
386
- func takeInheritingOptionalAsyncIsolatedAny( @_inheritActorContext fn: Optional < @isolated ( any) ( ) async -> ( ) > ) { }
386
+ func takeInheritingOptionalAsyncIsolatedAny( @_inheritActorContext fn: Optional < @isolated ( any) @ Sendable ( ) async -> ( ) > ) { }
387
387
388
388
// CHECK-LABEL: sil hidden [ossa] @$s4test7MyActorC0a20EraseInheritingAsyncC19ClosureIntoOptionalyyF
389
389
// CHECK: // function_ref closure #1
@@ -406,7 +406,7 @@ extension MyActor {
406
406
}
407
407
}
408
408
409
- func takeInheritingAsyncIsolatedAny_optionalResult( @_inheritActorContext fn: @escaping @isolated ( any) ( ) async -> Int ? ) { }
409
+ func takeInheritingAsyncIsolatedAny_optionalResult( @_inheritActorContext fn: @escaping @isolated ( any) @ Sendable ( ) async -> Int ? ) { }
410
410
411
411
// Test that we correctly handle isolation erasure from closures even when
412
412
// we can't completely apply the conversion as a peephole.
@@ -526,6 +526,6 @@ func testEraseAsyncActorIsolatedPartialApplication(a: MyActor) {
526
526
// CHECK-NEXT: end_borrow [[FN_BORROW]] : $@isolated(any) @Sendable @callee_guaranteed () -> ()
527
527
// CHECK-NEXT: destroy_value [[FN]] : $@isolated(any) @Sendable @callee_guaranteed () -> ()
528
528
// CHECK-NEXT: return [[RESULT]] : $Optional<any Actor>
529
- func extractIsolation( fn: @escaping @isolated ( any) ( ) -> Void ) -> ( any Actor ) ? {
529
+ func extractIsolation( fn: @escaping @isolated ( any) @ Sendable ( ) -> Void ) -> ( any Actor ) ? {
530
530
fn. isolation
531
531
}
0 commit comments