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 @@ -883,8 +883,18 @@ bool Decl::isStdlibDecl() const {
883
883
AvailabilityContext Decl::getAvailabilityForLinkage () const {
884
884
auto containingContext =
885
885
AvailabilityInference::annotatedAvailableRange (this , getASTContext ());
886
- if (containingContext.hasValue ())
886
+ if (containingContext.hasValue ()) {
887
+ // If this entity comes from the concurrency module, adjust it's
888
+ // availability for linkage purposes up to Swift 5.5, so that we use
889
+ // weak references any time we reference those symbols when back-deploying
890
+ // concurrency.
891
+ ASTContext &ctx = getASTContext ();
892
+ if (getModuleContext ()->getName () == ctx.Id_Concurrency ) {
893
+ containingContext->intersectWith (ctx.getConcurrencyAvailability ());
894
+ }
895
+
887
896
return *containingContext;
897
+ }
888
898
889
899
if (auto *accessor = dyn_cast<AccessorDecl>(this ))
890
900
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