Commit Graph

9 Commits

Author SHA1 Message Date
Alexis Laferrière
aa75341b20 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
2025-01-13 17:02:40 -08:00
Alexis Laferrière
24a74af40c Tests: Clarify entity naming in spi_members.swift 2025-01-07 11:20:26 -08:00
Allan Shortlidge
ac8aec32ea Sema: Correct the decl kind in a resilience diagnostic.
Not everything is a type, type checker.
2024-10-26 09:26:39 -07:00
Allan Shortlidge
49ce27acae Sema: Diagnose @_spi on elements of @frozen enums.
rdar://72873771
2022-11-29 22:11:02 -08:00
Slava Pestov
8af4405f36 AST: 'lazy' property initializers are never @inlinable
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.
2020-10-22 02:13:41 -04:00
Slava Pestov
fa50221d35 Sema: Use VarDecl::isLayoutExposedToClients() when checking VarDecl exportability 2020-10-22 01:45:56 -04:00
Slava Pestov
b4c568e2d1 Sema: Use VarDecl::isLayoutExposedToClients() when checking if @_spi attribute is allowed
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.
2020-10-22 01:11:56 -04:00
Slava Pestov
5f5372a3fc Sema: Don't check SPI violations in diagnoseInlinableDeclRefAccess()
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.
2020-10-22 01:11:46 -04:00
Slava Pestov
a824e5a33b Sema: Refactor getDisallowedOriginKind() to take an ExportContext
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.
2020-10-20 01:02:31 -04:00