Skip to content

Commit a77f05f

Browse files
committed
Switch @_unsafeSendable and @_unsafeMainActor tests to @_predatesConcurrency
1 parent 6907c94 commit a77f05f

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

test/ClangImporter/objc_async.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func testSlowServerSynchronous(slowServer: SlowServer) {
7676

7777
slowServer.overridableButRunsOnMainThread { s in
7878
print(s)
79-
onlyOnMainActor() // okay because parameter has @_unsafeMainActor
79+
onlyOnMainActor() // okay because parameter is @MainActor
8080
}
8181

8282
let _: Int = slowServer.overridableButRunsOnMainThread // expected-error{{cannot convert value of type '(((String) -> Void)?) -> Void' to specified type 'Int'}}

test/Concurrency/concurrent_value_checking.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func testConcurrency() {
136136
}
137137
}
138138

139-
func acceptUnsafeSendable(@_unsafeSendable _ fn: () -> Void) { }
139+
@_predatesConcurrency func acceptUnsafeSendable(_ fn: @Sendable () -> Void) { }
140140

141141
func testUnsafeSendableNothing() {
142142
var x = 5

test/Concurrency/global_actor_inference.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,9 @@ func acceptClosure<T>(_: () -> T) { }
505505
}
506506

507507
// ----------------------------------------------------------------------
508-
// Unsafe main actor parameter annotation
508+
// Main actor that predates concurrency
509509
// ----------------------------------------------------------------------
510-
func takesUnsafeMainActor(@_unsafeMainActor fn: () -> Void) { }
510+
@_predatesConcurrency func takesUnsafeMainActor(fn: @MainActor () -> Void) { }
511511

512512
@MainActor func onlyOnMainActor() { }
513513

test/Inputs/clang-importer-sdk/usr/include/ObjCConcurrency.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#pragma clang assume_nonnull begin
55

66
#define MAIN_ACTOR __attribute__((__swift_attr__("@MainActor")))
7-
#define MAIN_ACTOR_UNSAFE __attribute__((__swift_attr__("@_unsafeMainActor")))
87

98
#define NS_EXTENSIBLE_STRING_ENUM __attribute__((swift_wrapper(struct)));
109
typedef NSString *Flavor NS_EXTENSIBLE_STRING_ENUM;
@@ -86,7 +85,7 @@ typedef void (^CompletionHandler)(NSString * _Nullable, NSString * _Nullable_res
8685
-(void)asyncImportSame:(NSString *)operation completionHandler:(void (^)(NSInteger))handler;
8786
-(void)asyncImportSame:(NSString *)operation replyTo:(void (^)(NSInteger))handler __attribute__((swift_async(none)));
8887

89-
-(void)overridableButRunsOnMainThreadWithCompletionHandler:(MAIN_ACTOR_UNSAFE void (^ _Nullable)(NSString *))completion;
88+
-(void)overridableButRunsOnMainThreadWithCompletionHandler:(MAIN_ACTOR void (^ _Nullable)(NSString *))completion __attribute__((swift_attr("@_predatesConcurrency")));
9089
- (void)obtainClosureWithCompletionHandler:(void (^)(void (^_Nullable)(void),
9190
NSError *_Nullable,
9291
BOOL))completionHandler
@@ -171,7 +170,7 @@ void doSomethingConcurrently(__attribute__((noescape)) __attribute__((swift_attr
171170

172171

173172

174-
void doSomethingConcurrentlyButUnsafe(__attribute__((noescape)) __attribute__((swift_attr("@_unsafeSendable"))) void (^block)(void));
173+
void doSomethingConcurrentlyButUnsafe(__attribute__((noescape)) __attribute__((swift_attr("@Sendable"))) void (^block)(void)) __attribute__((swift_attr("@_predatesConcurrency")));
175174

176175

177176
MAIN_ACTOR MAIN_ACTOR __attribute__((__swift_attr__("@MainActor(unsafe)"))) @protocol TripleMainActor

test/SILGen/check_executor.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import _Concurrency
1515

1616
func takeClosure(_ fn: @escaping () -> Int) { }
1717

18-
func takeUnsafeMainActorClosure(@_unsafeMainActor _ fn: @escaping () -> Int) { }
18+
@_predatesConcurrency func takeUnsafeMainActorClosure(_ fn: @MainActor @escaping () -> Int) { }
1919

2020
public actor MyActor {
2121
var counter = 0

0 commit comments

Comments
 (0)