Skip to content

SIL: Ignore AEIC on package declaration inside declarations without effective public access #73708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/SIL/IR/SILDeclRef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,11 @@ SILLinkage SILDeclRef::getDefinitionLinkage() const {
case Limit::None:
return SILLinkage::Package;
case Limit::AlwaysEmitIntoClient:
return SILLinkage::PackageNonABI;
// Drop the AEIC if the enclosing decl is not effectively public.
// This matches what we do in the `internal` case.
if (isSerialized())
return SILLinkage::PackageNonABI;
else return SILLinkage::Package;
case Limit::OnDemand:
return SILLinkage::Shared;
case Limit::NeverPublic:
Expand Down
18 changes: 18 additions & 0 deletions test/SILGen/always_emit_into_client_attribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,21 @@ public final class C {
@_alwaysEmitIntoClient
deinit {}
}


// We drop AEIC if the containing context does not have effective public
// visibility.
internal struct InternalContext {
// CHECK-LABEL: sil hidden [ossa] @$s33always_emit_into_client_attribute15InternalContextV1vSivgZ
@_alwaysEmitIntoClient
internal static var v : Int { 1 }
}

// We drop AEIC if the containing context does not have effective public
// visibility.
package struct PackageContext {
// CHECK-LABEL: sil package [ossa] @$s33always_emit_into_client_attribute14PackageContextV1vSivgZ

@_alwaysEmitIntoClient
package static var v : Int { 1 }
}