File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -885,8 +885,10 @@ void AttributeChecker::visitSPIAccessControlAttr(SPIAccessControlAttr *attr) {
885
885
if (auto VD = dyn_cast<ValueDecl>(D)) {
886
886
// VD must be public or open to use an @_spi attribute.
887
887
auto declAccess = VD->getFormalAccess ();
888
+ auto DC = VD->getDeclContext ()->getAsDecl ();
888
889
if (declAccess < AccessLevel::Public &&
889
- !VD->getAttrs ().hasAttribute <UsableFromInlineAttr>()) {
890
+ !VD->getAttrs ().hasAttribute <UsableFromInlineAttr>() &&
891
+ !(DC && DC->isSPI ())) {
890
892
diagnoseAndRemoveAttr (attr,
891
893
diag::spi_attribute_on_non_public,
892
894
declAccess,
@@ -896,7 +898,9 @@ void AttributeChecker::visitSPIAccessControlAttr(SPIAccessControlAttr *attr) {
896
898
// Forbid stored properties marked SPI in frozen types.
897
899
if (auto property = dyn_cast<AbstractStorageDecl>(VD))
898
900
if (auto DC = dyn_cast<NominalTypeDecl>(D->getDeclContext ()))
899
- if (property->hasStorage () && !DC->isFormallyResilient ())
901
+ if (property->hasStorage () &&
902
+ !DC->isFormallyResilient () &&
903
+ !DC->isSPI ())
900
904
diagnoseAndRemoveAttr (attr,
901
905
diag::spi_attribute_on_frozen_stored_properties,
902
906
VD->getName ());
Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ func inlinable() -> SPIClass { // expected-error {{class 'SPIClass' is '@_spi' a
50
50
@frozen public struct SPIFrozenStruct {
51
51
var spiTypeInFrozen = SPIStruct ( )
52
52
private var spiTypeInFrozen1 : SPIClass
53
+
54
+ @_spi ( S)
55
+ private var privateSPIInFrozenSPI = SPIStruct ( )
53
56
}
54
57
55
58
private protocol PrivateProtocol { } // expected-note {{type declared here}}
You can’t perform that action at this time.
0 commit comments