Skip to content

Commit 3d4091c

Browse files
authored
Merge pull request #35982 from DougGregor/clang-importer-concurrency-tweaks
2 parents 222a988 + 9d5f631 commit 3d4091c

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8133,9 +8133,10 @@ void ClangImporter::Implementation::importAttributes(
81338133
// __attribute__((swift_attr("attribute")))
81348134
//
81358135
if (auto swiftAttr = dyn_cast<clang::SwiftAttrAttr>(*AI)) {
8136-
// FIXME: Hard-core @MainActor, because we don't have a point at which to
8137-
// do name lookup for imported entities.
8138-
if (swiftAttr->getAttribute() == "@MainActor") {
8136+
// FIXME: Hard-core @MainActor and @UIActor, because we don't have a
8137+
// point at which to do name lookup for imported entities.
8138+
if (swiftAttr->getAttribute() == "@MainActor" ||
8139+
swiftAttr->getAttribute() == "@UIActor") {
81398140
if (Type mainActorType = getMainActorType()) {
81408141
auto typeExpr = TypeExpr::createImplicit(mainActorType, SwiftContext);
81418142
auto attr = CustomAttr::create(SwiftContext, SourceLoc(), typeExpr);
@@ -9067,8 +9068,8 @@ ClangImporter::Implementation::createConstant(Identifier name, DeclContext *dc,
90679068
func->getAttrs().add(new (C) TransparentAttr(/*implicit*/ true));
90689069
// If we're in concurrency mode, mark the constant as @actorIndependent
90699070
if (SwiftContext.LangOpts.EnableExperimentalConcurrency) {
9070-
auto actorIndependentAttr = new (C) ActorIndependentAttr(SourceLoc(),
9071-
SourceRange(), ActorIndependentKind::Safe);
9071+
auto actorIndependentAttr = new (C) ActorIndependentAttr(
9072+
ActorIndependentKind::Unsafe, /*IsImplicit=*/true);
90729073
var->getAttrs().add(actorIndependentAttr);
90739074
}
90749075
// Set the function up as the getter.

test/ClangImporter/objc_async.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,6 @@ actor MySubclassCheckingSwiftAttributes : ProtocolWithSwiftAttributes {
9090
func mainActorMethod() {
9191
syncMethod() // expected-error{{actor-isolated instance method 'syncMethod()' can not be referenced from context of global actor 'MainActor'}}
9292
}
93+
94+
func uiActorMethod() { }
9395
}

test/IDE/print_clang_objc_async.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ 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

46-
// CHECK: @actorIndependent var MAGIC_NUMBER: Int32 { get }
47+
// CHECK: {{^}}var MAGIC_NUMBER: Int32 { get }

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)