Commit Graph

1087 Commits

Author SHA1 Message Date
Allan Shortlidge
b6a425ab6a Sema: Avoid diagnosing required availability in swiftinterface files.
The `-require-explicit-availability` compiler flag is designed to help
developers find declarations that they've written with missing availability.
The flag is not printed in swiftinterface files, though, so if a module has
both `-library-level=api` and also has `-require-explicity-availability=ignore`
(as the Swift stdlib does) then the result is that superfluous diagnostics are
emitted when typechecking the emitted module interface that should have been
suppressed by the `ignore` flag. Suppress these diagnostics when typechecking
swiftinterface files since they are only designed to be seen by the owner of
the module when they are building the module from source and they don't have
much value in the context of interface verification.
2025-04-01 07:12:50 -07:00
Allan Shortlidge
645628f3e4 Frontend: Reinstate suppression of warnings during interface type-checking.
We're not ready to start emitting warnings when type-checking modules from
interface. It is causing performance regressions and spurious diagnostics to be
emitted.

Reverts a small part of https://github.com/swiftlang/swift/pull/80360.

Resolves rdar://148257136.
2025-03-31 20:41:24 -07:00
Becca Royal-Gordon
65dc578de6 Merge pull request #80360 from beccadax/rdar144811653 2025-03-28 19:01:01 -07:00
Karoy Lorentey
5583e6916c Merge pull request #73258 from lorentey/you-cannot-escape-optionals
[stdlib] Generalize some constructs for non-escapable types
2025-03-27 20:02:00 -07:00
Becca Royal-Gordon
ce8cc1780a Ignore bad @_hasStorage in module interfaces
An objcImpl bug previously caused `@_hasStorage` to be emitted inside some extensions in module interfaces. An earlier commit in this PR created an error for this, but for backwards compatibility, it would actually be better to simply ignore the attribute in module interfaces. Modify TypeCheckStorage to emit a warning, not an error, in this situation.

Additionally, modify the module interface loader to show warnings when you verify a module interface, but not for other module interface uses (like compiling or importing one). The assumption here is that if you’re verifying a module interface, you’re either the author of the module that created it or you’re investigating a problem with it, and in either case you’d like to be told about minor defects in case they’re related.

Fixes rdar://144811653 thoroughly.
2025-03-27 18:25:11 -07:00
Becca Royal-Gordon
29a2d32d0e Avoid objcImpl @_hasStorage in module interfaces
If an `@objc implementation extension` had a public stored property with an observer, Swift would print `@_hasStorage` on the extension. This is Not Good because in a module interface, an objcImpl extension appears to be an ordinary extension, and properties in ordinary extensions are not supposed to have storage.

Suppress printing this attribute in objcImpl extensions to avoid this problem.

Partially fixes rdar://144811653 by suppressing emission of bad attributes.
2025-03-27 16:51:16 -07:00
Becca Royal-Gordon
c44284d874 Diagnose invalid @_hasStorage attributes
A bug in `@objc @implementation` is causing incorrect `@_hasStorage` attributes to be printed into module interfaces. As an initial step towards fixing this, diagnose bad `@_hasStorage` attributes and treat them as computed properties so that these malformed interfaces don’t cause compiler crashes.

Partially fixes rdar://144811653.
2025-03-27 16:24:44 -07:00
Becca Royal-Gordon
7703d115db Filter bad attrs out of module interface @abis
When printing an `@abi` attribute’s decl, we now filter out any attrs that are not valid in that position. Fixes a broken test.
2025-03-26 10:47:58 -07:00
Alexis Laferrière
a4aaa1063a Merge pull request #80098 from xymus/upstream-swiftmodule-blocklist
Frontend: Upstream blocklist check when ignoring adjacent swiftmodule files
2025-03-26 10:28:30 -07:00
Anthony Latsis
631a04e56c Merge pull request #80159 from AnthonyLatsis/danaus-plexippus-5
Sema: Extend adoption mode for `AsyncCallerExecution` to storage declarations
2025-03-26 04:40:58 +00:00
Anthony Latsis
8ad2e02596 Sema: Allow @execution on storage declarations 2025-03-25 02:07:04 +00:00
Anthony Latsis
d73402af25 AST: Restrict @execution to func and init declarations 2025-03-25 02:07:04 +00:00
Karoy Lorentey
9ecfac21ff [test] Adjust tests now that Optional supports nonescapable use
`Optional` is now depending on `$NonescapableTypes`, and thus the compiler no longer generates `#else` branches to allow suppressing that feature.
2025-03-24 12:15:57 -07:00
Karoy Lorentey
4ff38db976 [test] Adjust for Optional relying on $NonescapableTypes now 2025-03-24 12:15:50 -07:00
Alexis Laferrière
7d3ed787a1 Frontend: Upstream blocklist check in ignoring adjacent swiftmodule files 2025-03-19 14:15:34 -07:00
Andrew Trick
64a48d08e1 Update tests for strict @lifetime type checking 2025-03-19 11:59:04 -07:00
Pavel Yaskevich
bb6326bb32 [AST] Adjust usesFeatureExecutionAttribute to cover accessors 2025-03-14 17:29:48 -07:00
Doug Gregor
0cfa048c0a [Isolated conformances] Start parsing 'nonisolated' on conformances
It doesn't mean anything yet, but parse it and make sure it reproduces
in the module interface.
2025-03-12 23:18:31 -07:00
Doug Gregor
3837661b84 [Isolated conformances] Allow conformance isolation to differ from the type's
With the move to explicitly specifying the global actor for an isolated
conformance, we can now have conformances whose isolation differs from
that of the type, including having actors with global-actor-isolated
conformances. Introduce this generalization to match the proposal, and
update/add tests accordingly.
2025-03-12 23:18:28 -07:00
Doug Gregor
71a516b5f7 Print isolated conformances in textual interfaces 2025-03-12 23:18:14 -07:00
Alejandro Alonso
d0513a7aec Merge pull request #79665 from Azoy/value-generics-no-more-experiment
[AST] Make ValueGenerics feature always available
2025-03-10 15:14:34 -07:00
Allan Shortlidge
6284dd4895 Sema: Downgrade diagnostics about unavailable requirements in swiftinterfaces.
Historically, we've allowed protocol requirements to be written with
`@_spi_available` which makes them unavailable to clients of the public
`.swiftinterface`. Don't diagnose this when checking a `.swiftinterface` since
there's nothing the client can do about it.

Resolves rdar://146334181.
2025-03-07 12:02:42 -08:00
Alejandro Alonso
c1bb143648 Make ValueGenerics feature always available 2025-02-27 10:03:37 -08:00
Slava Pestov
fa86097035 Merge pull request #79647 from slavapestov/fix-rdar139465298
AST: Fix TypeBase::hasSimpleTypeRepr() for ProtocolCompositionType
2025-02-26 23:02:48 -05:00
Slava Pestov
c4e804a7d1 AST: Fix TypeBase::hasSimpleTypeRepr() for ProtocolCompositionType
Prior to the introduction of noncopyable generics, a ProtocolCompositionType
was 'simple' if it was exactly 'Any' or 'AnyObject'. Now, there is a new
simple case, where we have a single inverse requirement '~Copyable' or
'~Escapable', and the old logic was never updated to account for this
possibility. Instead, it would ignore inverses, so it would claim that
a composition like `P & ~Copyable` was simple when it shouldn't be.

Fixes rdar://139465298.
2025-02-26 16:56:27 -05:00
Pavel Yaskevich
c3b75ee0ef Merge pull request #79580 from xedin/extensible-enums
[Serialization/TypeChecker] Introduce `ExtensibleEnums` feature
2025-02-25 09:53:02 -08:00
Alastair Houghton
4c0e141ccc Merge pull request #79390 from al45tair/eng/PR-144497613
[Backtracing] Add warning suppression option, enable it for tests.
2025-02-25 17:51:28 +00:00
Alexis Laferrière
c539f7e11a Merge pull request #79588 from xymus/ignore-more-swiftmodules
Frontend: Ignore resilient binary swiftmodules under usr/lib/swift
2025-02-25 09:08:36 -08:00
Alastair Houghton
71abe6f26b [Tests] Disable backtracing in some tests.
These tests can be negatively affected by the warnings about unsupported
Swift backtracer settings.

rdar://144497613
2025-02-25 10:53:28 +00:00
Pavel Yaskevich
b84bf055f0 [TypeChecker] Implement ExtensibleEnums feature exhaustivily handling
If an enum comes from a different module that has `ExtensibleEnums`
feature enabled, unless it requires either `@unknown default:` or
`@frozen` because it is allowed to introduce new cases in the future
versions of the module.
2025-02-25 00:05:23 -08:00
Alexis Laferrière
f6ef819ecf Frontend: Test that we still use the adjacent swiftmodule for the stdlib 2025-02-24 16:22:20 -08:00
Alexis Laferrière
40244a2935 Frontend: Ignore resilient binary swiftmodules under usr/lib/swift
Most SDKs use only swiftinterfaces under usr/lib/swift. Let's make sure
we standardize this behavior and use only swiftinterface when they are
present, even if there are also binary swiftmodule files available.

Apply the same logic to SubFrameworks as well while we're at it.

rdar://145316821
2025-02-24 16:22:20 -08:00
Tony Allevato
7c258f2057 Merge pull request #79485 from allevato/index-swiftinterface
[Frontend] Support `-index-store-path` for explicit module interface compilation.
2025-02-21 12:55:49 -08:00
Pavel Yaskevich
dd1be8f6d4 [Frontend] Hide @execution attribute behind an experimental feature ExecutionAttribute
Since the proposal has not been approved yet we cannot expose
`@execution` attribute.
2025-02-20 00:05:03 -08:00
Pavel Yaskevich
e2ff3308be [Frontend] NFC: Rename NonIsolatedAsyncInheritsIsolationFromContext feature
New name is `AsyncCallerExecution` as stated by the proposal.
2025-02-19 20:00:56 -08:00
Tony Allevato
5fd985256c [Frontend] Support -index-store-path for explicit module interface compilation. 2025-02-19 12:42:48 -05:00
Allan Shortlidge
9c15342d08 Sema: Allow unavailable stored properties in swiftinterfaces.
In a swiftinterface a declaration could be unavailable because it was written
in source with an `@_spi_available` attribute so it isn't possible to safely
reject unavailable stored properties in that context.

Resolves rdar://144958440.
2025-02-16 21:04:19 -08:00
Allan Shortlidge
d00e102fd1 Frontend: Remove the -skip-import-in-public-interface flag.
This flag is unsafe since the compiler does not verify that the resulting
public interface will compile with the module import removed. The modern
alternative to this flag is `@_spiOnly import`. Since the flag is no longer
used by any projects it should be removed.

Resolves rdar://134351088.
2025-02-09 18:52:10 -08:00
Meghana Gupta
98c7df228d Disable pre ossa modules tests 2025-01-30 17:10:04 -08:00
Erik Eckstein
830565b0f0 - test changes 2025-01-30 17:10:03 -08:00
Artem Chikin
5eb471730d Merge pull request #78867 from artemcm/NoPackageOnlyImportOnImplicitBuild
[ModuleInterface] Determine package-only resolution need based on input mode
2025-01-24 14:35:22 -08:00
Artem Chikin
a00c1ee7e5 [ModuleInterface] Determine package-only resolution need based on input mode
Instead of requested action. In implicit builds, implicit interface build sub-invocations inherit their parent invocation's requested action, which the code was failing to detect that we were building an interface, not source, and erroneously resulted in enabling in-package module dependency resolution.

Resolves rdar://143505814
2025-01-23 14:11:16 -08:00
Joe Groff
5d0fe0a156 Merge pull request #78705 from jckarter/explicit-conditional-invertible-extension-requirements
Require explicit statement of all `Copyable`/`Escapable` requirements for conditional `Copyable`/`Escapable` conformances.
2025-01-22 09:52:26 -08:00
Andrew Trick
5066dd9f90 Merge pull request #78716 from atrick/fix-lifedep-out
Fix LifetimeDependenceDiagnostics for @out dependencies
2025-01-22 00:17:50 -08:00
Joe Groff
a0a26b8330 Require explicit statement of all Copyable/Escapable requirements for conditional Copyable/Escapable conformances.
As specified by the SE-0446 acceptance, extensions that declare a type's
conditional `Copyable` or `Escapable` ability must reiterate explicitly all
of the `Copyable` and/or `Escapable` requirements, whether required or not
required (by e.g. `~Copyable`) that were suppressed in the original
type declaration.
2025-01-21 09:36:39 -08:00
Pavel Yaskevich
82e111a276 Merge pull request #78704 from xedin/rdar-142920095
Implement experimental`@execution(concurrent | caller)` attribute
2025-01-21 09:04:39 -08:00
Allan Shortlidge
17e2262449 Revert "AST: Print opaque result types correctly in swiftinterfaces."
This reverts commit 902892a59f.
2025-01-19 09:56:51 -08:00
Pavel Yaskevich
fc1e650b89 [Tests] NFC: Add serialization test for @execution(...) attribute 2025-01-17 15:40:01 -08:00
Andrew Trick
ffb1137348 Update lifetime_dependence tests for stricter diagnostics. 2025-01-17 11:19:04 -08:00
Allan Shortlidge
250479177e Merge pull request #78653 from tshortli/suppress-option-parsing-warnings-in-swiftinterfaces
Frontend: Honor warning suppression when parsing arguments from swiftinterfaces
2025-01-15 09:45:40 -08:00