Skip to content

Commit 1ae79db

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 d40fdb4 commit 1ae79db

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
@@ -758,7 +758,7 @@ SILLinkage LinkEntity::getLinkage(ForDefinition_t forDefinition) const {
758758
case Kind::DispatchThunkAllocatorAsyncFunctionPointer:
759759
case Kind::PartialApplyForwarderAsyncFunctionPointer:
760760
return getUnderlyingEntityForAsyncFunctionPointer()
761-
.getLinkage(ForDefinition);
761+
.getLinkage(forDefinition);
762762
case Kind::KnownAsyncFunctionPointer:
763763
return SILLinkage::PublicExternal;
764764
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)