File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
test/Concurrency/Backdeploy Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -871,8 +871,18 @@ bool Decl::isStdlibDecl() const {
871
871
AvailabilityContext Decl::getAvailabilityForLinkage () const {
872
872
auto containingContext =
873
873
AvailabilityInference::annotatedAvailableRange (this , getASTContext ());
874
- if (containingContext.hasValue ())
874
+ if (containingContext.hasValue ()) {
875
+ // If this entity comes from the concurrency module, adjust it's
876
+ // availability for linkage purposes up to Swift 5.5, so that we use
877
+ // weak references any time we reference those symbols when back-deploying
878
+ // concurrency.
879
+ ASTContext &ctx = getASTContext ();
880
+ if (getModuleContext ()->getName () == ctx.Id_Concurrency ) {
881
+ containingContext->intersectWith (ctx.getConcurrencyAvailability ());
882
+ }
883
+
875
884
return *containingContext;
885
+ }
876
886
877
887
if (auto *accessor = dyn_cast<AccessorDecl>(this ))
878
888
return accessor->getStorage ()->getAvailabilityForLinkage ();
Original file line number Diff line number Diff line change
1
+ // RUN: %empty-directory(%t)
2
+ // RUN: %target-swift-frontend %s -target x86_64-apple-macosx12.0 -module-name main -emit-ir -o %t/new.ir
3
+ // RUN: %FileCheck %s --check-prefix=NEW < %t/new.ir
4
+ // RUN: %target-swift-frontend %s -target x86_64-apple-macosx10.15 -module-name main -emit-ir -o %t/old.ir -disable-availability-checking
5
+ // RUN: %FileCheck %s --check-prefix=OLD < %t/old.ir
6
+
7
+ // REQUIRES: OS=macosx
8
+
9
+ // NEW-NOT: extern_weak
10
+ // OLD: @"$sScPMn" = extern_weak global
11
+ // OLD: declare extern_weak swiftcc i8* @swift_task_alloc
12
+ // OLD: declare extern_weak swiftcc %swift.metadata_response @"$sScPMa"
13
+ // OLD: declare extern_weak swiftcc i8 @"$sScP8rawValues5UInt8Vvg"
14
+
15
+ @available ( macOS 12 . 0 , * )
16
+ public func g( ) async -> String { " hello " }
17
+
18
+ @available ( macOS 12 . 0 , * )
19
+ public func f( ) async {
20
+ Task {
21
+ print ( await g ( ) )
22
+ }
23
+ }
You can’t perform that action at this time.
0 commit comments