Skip to content

Commit a8f91c4

Browse files
committed
[Clang importer] Allow @UIActor as an alias for @mainactor.
We've flip-flopped on the name a bit. Accept both for now.
1 parent c732ba3 commit a8f91c4

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8036,9 +8036,10 @@ void ClangImporter::Implementation::importAttributes(
80368036
// __attribute__((swift_attr("attribute")))
80378037
//
80388038
if (auto swiftAttr = dyn_cast<clang::SwiftAttrAttr>(*AI)) {
8039-
// FIXME: Hard-core @MainActor, because we don't have a point at which to
8040-
// do name lookup for imported entities.
8041-
if (swiftAttr->getAttribute() == "@MainActor") {
8039+
// FIXME: Hard-core @MainActor and @UIActor, because we don't have a
8040+
// point at which to do name lookup for imported entities.
8041+
if (swiftAttr->getAttribute() == "@MainActor" ||
8042+
swiftAttr->getAttribute() == "@UIActor") {
80428043
if (Type mainActorType = getMainActorType()) {
80438044
auto typeExpr = TypeExpr::createImplicit(mainActorType, SwiftContext);
80448045
auto attr = CustomAttr::create(SwiftContext, SourceLoc(), typeExpr);

test/IDE/print_clang_objc_async.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import _Concurrency
4040
// CHECK-NEXT: @actorIndependent func independentMethod()
4141
// CHECK-NEXT: @asyncHandler func asyncHandlerMethod()
4242
// CHECK-NEXT: @MainActor func mainActorMethod()
43+
// CHECK-NEXT: @MainActor func uiActorMethod()
4344
// CHECK-NEXT: {{^}} optional func missingAtAttributeMethod()
4445
// CHECK-NEXT: {{^[}]$}}
4546

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ typedef void (^CompletionHandler)(NSString * _Nullable, NSString * _Nullable_res
8282
-(void)independentMethod __attribute__((__swift_attr__("@actorIndependent")));
8383
-(void)asyncHandlerMethod __attribute__((__swift_attr__("@asyncHandler")));
8484
-(void)mainActorMethod __attribute__((__swift_attr__("@MainActor")));
85+
-(void)uiActorMethod __attribute__((__swift_attr__("@UIActor")));
8586

8687
@optional
8788
-(void)missingAtAttributeMethod __attribute__((__swift_attr__("asyncHandler")));

0 commit comments

Comments
 (0)