Skip to content

Commit dc7f30f

Browse files
authored
Merge pull request #85387 from xymus/exportability-nle-proto
Sema: Exportability check protocols in non-library-evolution mode
2 parents 4d8d719 + afe335d commit dc7f30f

File tree

3 files changed

+292
-24
lines changed

3 files changed

+292
-24
lines changed

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ SIMPLE_DECL_ATTR(_alwaysEmitIntoClient, AlwaysEmitIntoClient,
474474
83)
475475

476476
SIMPLE_DECL_ATTR(_implementationOnly, ImplementationOnly,
477-
OnImport | OnFunc | OnConstructor | OnVar | OnSubscript | OnStruct | OnClass | OnEnum,
477+
OnImport | OnFunc | OnConstructor | OnVar | OnSubscript | OnNominalType,
478478
UserInaccessible | ABIStableToAdd | ABIStableToRemove | APIStableToAdd | APIStableToRemove | UnreachableInABIAttr,
479479
84)
480480

lib/Sema/TypeCheckAccess.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2163,13 +2163,12 @@ swift::getDisallowedOriginKind(const Decl *decl,
21632163
Feature::AssumeResilientCxxTypes))
21642164
return DisallowedOriginKind::FragileCxxAPI;
21652165

2166-
if (isa<StructDecl>(decl) || isa<EnumDecl>(decl)) {
2167-
if (decl->getASTContext().LangOpts.hasFeature(
2168-
Feature::CheckImplementationOnly) &&
2169-
decl->getAttrs().hasAttribute<ImplementationOnlyAttr>()) {
2170-
return DisallowedOriginKind::ImplementationOnlyMemoryLayout;
2171-
}
2172-
}
2166+
// Implementation-only memory layouts for non-library-evolution mode.
2167+
if (isa<NominalTypeDecl>(decl) &&
2168+
decl->getASTContext().LangOpts.hasFeature(
2169+
Feature::CheckImplementationOnly) &&
2170+
decl->getAttrs().hasAttribute<ImplementationOnlyAttr>())
2171+
return DisallowedOriginKind::ImplementationOnlyMemoryLayout;
21732172

21742173
// Report non-public import last as it can be ignored by the caller.
21752174
// See \c diagnoseValueDeclRefExportability.

0 commit comments

Comments
 (0)