Commit Graph

17 Commits

Author SHA1 Message Date
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
Alexis Laferrière
915b1e3def Sema: Update more tests with more precise message about exported conformances 2024-06-13 15:20:18 -07:00
Becca Royal-Gordon
3732c75e97 Adopt %kind for certain access control diagnostics
These particular changes slightly alter some diagnostics.
2023-07-19 13:06:51 -07:00
Ellie Shin
32f53d1eb8 Add implicit SPI import feature
API development sometimes requires a redesign while supporting early
adopters. Currently this is done by adding @_spi(name) to the API but
that requires adding the attribute in import statements as well, causing
manual overhead of adding and then removing when the redesign is done.

This PR introduces a special spi group name '_' and allows an implicit
spi import of a module containing API attributed with '@_spi(_)'

Resolves rdar://109797632
2023-06-01 15:33:04 -07:00
Allan Shortlidge
f11eaf16eb Sema: Diagnose accessor exportability.
Properties may have `@_spi` setters and therefore the exportability of a
referenced accessor may differ from the exportability of the storage.
2023-05-01 15:34:08 -07:00
Ellie Shin
ef321c9fd2 Allow @usableFromInline and @inlinable to package decls
Add tests for packgae inline
Add more package acl tests

Resolves rdar://104617133
2023-03-16 11:21:11 -07: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
f48aa51884 Sema: Remove ExportabilityChecker
Availability checking already knows how to check exportability for
types and conformances referenced from inlinable function signatures
and bodies.

Let's generalize this to work on non-inlinable function signatures
as well, allowing us to get rid of the ExportabilityChecker altogether.
2020-10-20 01:00:43 -04:00
Slava Pestov
94e999a1b5 Sema: Pull availability checking out of resolveType()
We used to diagnose references to unavailable declarations in
two places:

- inside Exprs, right after type checking the expression
- inside TypeReprs, from resolveType()

In broad terms, resolveType() is called with TypeReprs
stored inside both Stmts and Decls.

To handle the first case, I added a new overload of
diagAvailability() that takes a Stmt, to be called from
typeCheckStmt(). This doesn't actually walk into any Exprs
stored inside the statement; this means it only walks
Patterns and such.

For the second case, a new DeclAvailabilityChecker is
now defined in TypeCheckAccess.cpp. It's structure is
analogous to the other three walkers there:

- AccessControlChecker
- UsableFromInlineChecker
- ExportabilityChecker

The new implementation of availability checking for types
introduces a lot more code than the old online logic
it replaces. However, I hope to consolidate some of the
code duplication among the four checkers that are defined
in TypeCheckAccess.cpp, and do some other cleanups that
will make the benefit of the new approach apparent.
2020-10-14 23:42:02 -04:00
Alexis Laferrière
c133693ac6 [Sema] Accept more use of @_spi as it can be generated in swiftinterface 2020-09-16 11:20:59 -07:00
Alexis Laferrière
dac3922090 [Sema] Accept use of SPI in inlinable SPI declarations
rdar://63978500
rdar://63189125
2020-09-16 11:20:56 -07:00
Alexis Laferrière
cbb7228451 [Sema] Evaluate SPI groups for all decls, not only public ones
Remove the fast path skipping evaluating SPI groups for non-public
decls. This knowledge is still required to allow the use of SPI types in
the signatures of `@usableFromInline` declarations and in internal
properties of structs in non library evolution compilation.

rdar://68530659
rdar://68527580
2020-09-08 16:58:45 -07:00
Alexis Laferrière
63d9acda3e [Sema] Report public use of local SPIs by the exportability checker
This change improves slightly the quality of the diagnostics and detects
the use of local SPI types on public property with a default value.
2020-06-29 11:18:04 -07:00
Alexis Laferrière
6bead5c436 [Parse] Fix source range of SPI attributes
rdar://problem/63554849
2020-05-26 12:56:36 -07:00
Alexis Laferrière
d004f8403c [Sema] Forbid stored property marked SPI in frozen structs 2020-05-12 13:37:34 -07:00
Alexis Laferrière
412469326d [SPI Test] Extend and update SPI tests 2020-03-04 16:43:05 -08:00
Alexis Laferrière
b14fdd30de [Test] SPI access and limits when used locally 2020-02-19 14:17:14 -08:00