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
In @frozen structs, stored properties and property wrappers must
have inlinable initial value expressions, since they are re-emitted
into designated initializer bodies, which themselves might be
@inlinable.
However, 'lazy' properties don't follow this pattern; the
initial value expression is emitted inside the getter, which
is never @inlinable.
We need to prohibit 'lazy' properties and property wrappers from
being declared @_spi inside of a @frozen struct. Making them SPI
doesn't make sense, because these properties will be omitted from the
module interface and not taken into account when clients manipulate
values of this type.
There's no need to check for that here, because we also run
diagnoseDeclRefExportability() on declarations referenced
from inlinable code.
This changes some diagnostics; we now produce the same diagnostic
for references to SPI types in declaration signatures and for
references to non-type SPI declarations in inlinable function bodies.
Also note that the old inlinable reference diagnostic no longer has
to handle the 'public' and 'open' access levels, which previously
happened for '@_spi'; so I changed those entries in the %select to
%error.
Converting the innermost DeclContext into a Decl won't work if
the innermost DeclContext is the parent context of a VarDecl.
Instead, use the relevant bit of state from the ExportContext,
which is computed correctly.
This fixes a regression caused by an earlier commit in this PR
which our test suite did not catch.