Sema: Accessors's SPI are tied to the attributes on the storage

Recent changes started using SPIGroupRequest on accessors specifically
to verify access to the wrappedValue of PropertyWrappers within the
direct access logic on variables using the property wrapper. Update
SPIGroupRequest to support this request and the type-checking logic to
accept the @_spi attribute on internal usable from inline accessors.

rdar://141964200
This commit is contained in:
Alexis Laferrière
2025-01-06 16:34:15 -08:00
parent 24a74af40c
commit aa75341b20
4 changed files with 161 additions and 2 deletions

View File

@@ -3191,6 +3191,14 @@ SPIGroupsRequest::evaluate(Evaluator &evaluator, const Decl *decl) const {
spiGroups.insert(originalSPIs.begin(), originalSPIs.end());
}
// Accessors get the SPI groups from the PBD.
if (auto AD = dyn_cast<AccessorDecl>(decl))
if (auto VD = dyn_cast<VarDecl>(AD->getStorage()))
if (auto *PBD = VD->getParentPatternBinding()) {
auto moreGroups = PBD->getSPIGroups();
spiGroups.insert(moreGroups.begin(), moreGroups.end());
}
// If there is no local SPI information, look at the context.
if (spiGroups.empty()) {