Skip to content

Commit 7d30d04

Browse files
committed
Fix linkage for references to async function pointers.
We were not making references to async function pointers "weak" when the function itself was weak, because we were always calculating linkage as-if we were defining the async function pointer. Fixes the rest of rdar://79674106.
1 parent 4a22454 commit 7d30d04

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/IRGen/Linking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
752752
case Kind::DispatchThunkAllocatorAsyncFunctionPointer:
753753
case Kind::PartialApplyForwarderAsyncFunctionPointer:
754754
return getUnderlyingEntityForAsyncFunctionPointer()
755-
.getLinkage(ForDefinition);
755+
.getLinkage(forDefinition);
756756
case Kind::KnownAsyncFunctionPointer:
757757
return SILLinkage::PublicExternal;
758758
case Kind::PartialApplyForwarder:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %target-swift-frontend -enable-implicit-dynamic -target %target-cpu-apple-macosx11 -Onone -emit-ir %s | %FileCheck --check-prefix=MAYBE-AVAILABLE %s
2+
// REQUIRES: OS=macosx && CPU=x86_64
3+
4+
@available(macOS 12.0, *)
5+
public func f<S: AsyncSequence>(_ s: S) async throws -> Any.Type {
6+
for try await _ in s { }
7+
8+
typealias Fn = @MainActor () -> S.Element
9+
return Fn.self
10+
}
11+
12+
// MAYBE-AVAILABLE: @"$sScI4next7ElementQzSgyYaKFTjTu" = extern_weak global
13+
// MAYBE-AVAILABLE: declare{{.*}} extern_weak{{.*}} @swift_getFunctionTypeMetadataGlobalActor

0 commit comments

Comments
 (0)