Skip to content

Commit 769cfce

Browse files
authored
Merge pull request swiftlang#35499 from etcwilde/ewilde/actor-independent-macro-import
[Concurrency] Imported macros are actor independent
2 parents ae7e1b5 + 8f81609 commit 769cfce

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8953,7 +8953,12 @@ ClangImporter::Implementation::createConstant(Identifier name, DeclContext *dc,
89538953

89548954
// Mark the function transparent so that we inline it away completely.
89558955
func->getAttrs().add(new (C) TransparentAttr(/*implicit*/ true));
8956-
8956+
// If we're in concurrency mode, mark the constant as @actorIndependent
8957+
if (SwiftContext.LangOpts.EnableExperimentalConcurrency) {
8958+
auto actorIndependentAttr = new (C) ActorIndependentAttr(SourceLoc(),
8959+
SourceRange(), ActorIndependentKind::Safe);
8960+
var->getAttrs().add(actorIndependentAttr);
8961+
}
89578962
// Set the function up as the getter.
89588963
makeComputed(var, func, nullptr);
89598964

test/IDE/print_clang_objc_async.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,5 @@ import _Concurrency
4242
// CHECK-NEXT: @MainActor func mainActorMethod()
4343
// CHECK-NEXT: {{^}} optional func missingAtAttributeMethod()
4444
// CHECK-NEXT: {{^[}]$}}
45+
46+
// CHECK: @actorIndependent var MAGIC_NUMBER: Int32 { get }

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,6 @@ typedef void (^CompletionHandler)(NSString * _Nullable, NSString * _Nullable_res
7777
-(void)missingAtAttributeMethod __attribute__((__swift_attr__("asyncHandler")));
7878
@end
7979

80+
#define MAGIC_NUMBER 42
81+
8082
#pragma clang assume_nonnull end

0 commit comments

Comments
 (0)