Skip to content

Commit c133693

Browse files
committed
[Sema] Accept more use of @_spi as it can be generated in swiftinterface
1 parent 2451e68 commit c133693

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,10 @@ void AttributeChecker::visitSPIAccessControlAttr(SPIAccessControlAttr *attr) {
885885
if (auto VD = dyn_cast<ValueDecl>(D)) {
886886
// VD must be public or open to use an @_spi attribute.
887887
auto declAccess = VD->getFormalAccess();
888+
auto DC = VD->getDeclContext()->getAsDecl();
888889
if (declAccess < AccessLevel::Public &&
889-
!VD->getAttrs().hasAttribute<UsableFromInlineAttr>()) {
890+
!VD->getAttrs().hasAttribute<UsableFromInlineAttr>() &&
891+
!(DC && DC->isSPI())) {
890892
diagnoseAndRemoveAttr(attr,
891893
diag::spi_attribute_on_non_public,
892894
declAccess,
@@ -896,7 +898,9 @@ void AttributeChecker::visitSPIAccessControlAttr(SPIAccessControlAttr *attr) {
896898
// Forbid stored properties marked SPI in frozen types.
897899
if (auto property = dyn_cast<AbstractStorageDecl>(VD))
898900
if (auto DC = dyn_cast<NominalTypeDecl>(D->getDeclContext()))
899-
if (property->hasStorage() && !DC->isFormallyResilient())
901+
if (property->hasStorage() &&
902+
!DC->isFormallyResilient() &&
903+
!DC->isSPI())
900904
diagnoseAndRemoveAttr(attr,
901905
diag::spi_attribute_on_frozen_stored_properties,
902906
VD->getName());

test/SPI/local_spi_decls.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func inlinable() -> SPIClass { // expected-error {{class 'SPIClass' is '@_spi' a
5050
@frozen public struct SPIFrozenStruct {
5151
var spiTypeInFrozen = SPIStruct()
5252
private var spiTypeInFrozen1: SPIClass
53+
54+
@_spi(S)
55+
private var privateSPIInFrozenSPI = SPIStruct()
5356
}
5457

5558
private protocol PrivateProtocol {} // expected-note {{type declared here}}

0 commit comments

Comments
 (0)