Skip to content

Commit 8c0a444

Browse files
tshortlimeg-gupta
authored andcommitted
SIL: Allow package decls to be serialized when appropriate.
swiftlang#70100 prohibited `package` declarations from ever being serialized in order to solve a problem in which the declarations were being serialized inappropriately. That's too heavy handed, though, because an `@_alwaysEmitIntoClient` function with `package` access *must* be serialized because it has public non-abi linkage. Resolves rdar://104711625
1 parent 9cd95a1 commit 8c0a444

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

lib/SIL/IR/SILDeclRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ IsSerialized_t SILDeclRef::isSerialized() const {
844844
}
845845

846846
// Anything else that is not public is not serializable.
847-
if (d->getEffectiveAccess() < AccessLevel::Public || d->hasPackageAccess())
847+
if (d->getEffectiveAccess() < AccessLevel::Public)
848848
return IsNotSerialized;
849849

850850
// Enum element constructors are serializable if the enum is

test/SILGen/always_emit_into_client_attribute.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-emit-silgen -primary-file %s %S/Inputs/always_emit_into_client_other_file.swift | %FileCheck %s
1+
// RUN: %target-swift-emit-silgen -primary-file %s %S/Inputs/always_emit_into_client_other_file.swift -package-name Package | %FileCheck %s
22

33
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute0A22EmitIntoClientFunctionyyF : $@convention(thin) () -> ()
44
@_alwaysEmitIntoClient public func alwaysEmitIntoClientFunction() {
@@ -12,6 +12,17 @@
1212
alwaysEmitIntoClientOtherFunction()
1313
}
1414

15+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute35packageAlwaysEmitIntoClientFunctionyyF : $@convention(thin) () -> ()
16+
@_alwaysEmitIntoClient package func packageAlwaysEmitIntoClientFunction() {
17+
alwaysEmitIntoClientOtherFunction()
18+
}
19+
20+
// FIXME: @_alwaysEmitIntoClient should not be allowed on private decls
21+
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute35privateAlwaysEmitIntoClientFunction33_5D0713A780245A446371C699E6F23C4FLLyyF : $@convention(thin) () -> ()
22+
@_alwaysEmitIntoClient private func privateAlwaysEmitIntoClientFunction() {
23+
alwaysEmitIntoClientOtherFunction()
24+
}
25+
1526
public struct S {
1627
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SV8propertySivg : $@convention(method) (S) -> Int
1728
// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s33always_emit_into_client_attribute1SV8propertySivs : $@convention(method) (Int, @inout S) -> ()

0 commit comments

Comments
 (0)