Commit Graph

11 Commits

Author SHA1 Message Date
Doug Gregor
d03427691b Update one more test for diagnostic change 2025-11-08 10:53:58 -08:00
Doug Gregor
020b69d4b6 [SE-0497] Implement @export attribute syntax
Implement the @export(implementation) and @export(interface) attributes
to replace @_alwaysEmitIntoClient and @_neverEmitIntoClient. Provide a
warning + Fix-It to start staging out the very-new
@_neverEmitIntoClient. We'll hold off on pushing folks toward
@_alwaysEmitIntoClient for a little longer.
2025-11-07 22:00:40 -08:00
Alexis Laferrière
e04dac5523 Sema: Embedded can reference typealiases to non-publicly imported types 2025-11-04 14:41:08 -08:00
Alexis Laferrière
0e7077db0a Sema: Allow embedded code to reference SPI
Embedded mode use only binary swiftmodules for distribution, SPI will
always be visible. We can allow implicitly always-emit-into-client
function bodies from the embedded mode to references SPIs.

rdar://163519075
2025-10-28 11:29:57 -07:00
Alexis Laferrière
2d339c1260 Sema: Custom diagnostic for var decls referencing a restricted type
Replace the `here` part of the generic exportability diagnostic for
variables with: `in a property declaration marked public or in a
'@frozen' or '@usableFromInline' context`.

The full diagnostic now looks like:
```
error: cannot use struct 'ImportedType' in a property declaration marked
public or in a '@frozen' or '@usableFromInline' context;
'HiddenDependency' has been imported as implementation-only
```

This should be improved further to support implicitly exported memory
layouts in non-library-evolution and embedded.
2025-10-21 11:30:52 -07:00
Alexis Laferrière
938050720e Sema: Use -verify-ignore-unrelated in tests 2025-10-14 14:14:55 -07:00
Alexis Laferrière
f758e210f1 Sema: Add requires to IOI + embedded code using the stdlib 2025-10-14 14:14:55 -07:00
Alexis Laferrière
efbc938694 Sema: Allow nested structs in embedded code 2025-10-14 14:14:55 -07:00
Alexis Laferrière
495035d612 Sema: Add tests for embedded exportability checking with accessors 2025-10-14 14:14:55 -07:00
Alexis Laferrière
0136e19dae Sema: Allow availability macros in embedded code
Availability macros are rejected from library-evolution inlinable code
as the compiler didn't know how to print them in the swiftinterface.
This isn't a concern with the embedded style of fragile functions, we
can allow availability macros there.
2025-10-14 14:14:55 -07:00
Alexis Laferrière
1b086e1bfc Sema: Embedded functions are fragile unless marked otherwise
Consider functions in embedded mode to be fragile unless marked with
`@_neverEmitIntoClient`. Basically treating them as if they were
`@_alwaysEmitIntoClient` by default. A fragile function cannot reference
restricted imports such as `@_implementationOnly`, `internal import`,
etc.

We consider them as fragile only for type-checking, at the SIL level
they remain treated as normal functions like before. This allows the
later optimization to work as expected. We may want to likely align both
ends of the compiler once this is properly supported in sema.

This is enabled only in embedded. Fragile functions in library-evolution
are marked with attributes and are already checked. We do not need this
is non-embedded non-library-evolution as CMO handles inlining and
already takes into consideration `@_implementationOnly` imports.

Note: We'll need a similar check for memory layouts exposed to clients.
We can still see compiler crashes and miscompiles in this scenario. This
will apply to both embedded and non-library-evolution modes. That will
likely need to extend the `@_neverEmitIntoClient` attribute and may
require a staged deployment.

rdar://161365361
2025-10-14 14:14:54 -07:00