Commit Graph

1165 Commits

Author SHA1 Message Date
Allan Shortlidge
fba664c082 Revert "Frontend: Require explicit language mode when emitting swiftinterfaces."
This reverts commit 9067051c29.
2025-09-25 08:02:18 -07:00
Konrad Malawski
3b3c36457a [Distributed] fix missing availability annotation
resolves rdar://161100405
2025-09-23 15:56:05 +09:00
Konrad `ktoso` Malawski
6f4c26f29a Merge pull request #84384 from ktoso/wip-distributed-red-conf 2025-09-22 21:00:26 +09:00
Alexis Laferrière
97002e1ee0 Merge pull request #84373 from xymus/le-import-warn
Sema: Limit errors on LE importing non-LE modules to SDK modules
2025-09-19 16:34:48 -07:00
Konrad Malawski
7affd14c24 fix assertions in other test 2025-09-19 15:44:11 +09:00
Konrad Malawski
1ea4e914e3 Simplify the check; conforming to (Distributed)Actor is not right in any case 2025-09-19 10:50:23 +09:00
Konrad Malawski
d73b907d66 [Distributed] Avoid redundant conformance to DistributedActor in interface files
Forgetting to handle DistributedActor next to Actor strikes again:
Actors are special that their conformance is implicit and needs not be
printed in swift interface files.

an actor's Actor conformance was filtered out, however the same logic
needs to be applied to DistributedActor, as otherwise there can be
redundant conformance errors when validating module interface files.

Resolves rdar://160252579
2025-09-19 09:01:23 +09:00
Alexis Laferrière
8b38d29333 Sema: Limit error on LE importing non-LE modules to SDK modules
Limit reporting as an error imports of a non-library-evolution module
from a library-evolution enabled module to sources that are part of the
SDK. The error also requires having enabled `InternalImportsByDefault`.
This should help prevent SDK breaking regressions while loosening the
restriction elsewhere.

Framework owners can enable `-library-level api` or `spi` to get this
check as an error, along with more sanity checks.

Other cases remain as a warning. We should look to silence it in some
cases or offer a flag to do so.

rdar://160414667
2025-09-18 11:31:36 -07:00
Allan Shortlidge
c78725359b Merge pull request #84327 from tshortli/really-require-swift-version-in-module-interfaces
Frontend: Require explicit language mode when emitting swiftinterfaces
2025-09-16 15:57:26 -07:00
Allan Shortlidge
01d458b7a3 Merge pull request #84311 from tshortli/preconcurrency-import-in-swiftinterface
ModuleInterface: Print imports with @preconcurrency in swiftinterface files
2025-09-16 13:09:48 -07:00
Allan Shortlidge
9067051c29 Frontend: Require explicit language mode when emitting swiftinterfaces.
If a .swiftinterface file does not include an explicit `-language-mode` option
(or its predecessor `-swift-version`) and needs to be built as a dependency of a
client compilation, then the invocation to build the module from interface
would end up inheriting the language mode that the client code is built with.
This can result in spurious type checking diagnostics or even mis-compilation.
To ensure that a module interface is always built using the language mode that
its source code was originally built with, require an explicit `-language-mode`
option when emitting swiftinterface files.

In https://github.com/swiftlang/swift/pull/84307 this diagnostic was downgraded
to a warning. The failures it caused in PR testing should now be resolved.

Resolves rdar://145168219.
2025-09-16 10:25:14 -07:00
Allan Shortlidge
4841bcffa1 ModuleInterface: Print imports with @preconcurrency in swiftinterface files.
When a module has been imported `@preconcurrency` in source, when it is printed
in a `swiftinterface` file it should be printed along with the attribute to
ensure that type checking of the module's public declarations behaves
consistently.

This fix is a little unsatisfying because it adds another a linear scan over
all imports in the source for each printed import. This should be improved, but
it can be done later.

Resolves rdar://136857313.
2025-09-15 17:33:13 -07:00
Allan Shortlidge
e2c8235a2c Frontend: Temporarily downgrade 'error_module_interface_requires_language_mode'.
Downgrade the new error in https://github.com/swiftlang/swift/pull/84244 to a
warning.

The PR smoke test build is using a different build system that is failing to
pass `-swift-version` arguments when building various stdlib modules. That
needs to be fixed, but for now we also need to unblock CI.
2025-09-15 14:10:24 -07:00
Allan Shortlidge
cfe9f90347 Merge pull request #84244 from tshortli/require-swift-version-in-module-interfaces
Frontend: Require `-language-mode` option when emitting swiftinterfaces
2025-09-15 10:08:23 -07:00
Slava Pestov
87cbb7d2d0 AST: New way of printing @_opaqueReturnTypeOf when parameter packs are involved
This is the ASTPrinter change to go with the Sema change.
We now print @_opaqueReturnTypeOf using the new nested
syntax when parameter packs are involved.

Fixes rdar://problem/151171381.
2025-09-12 15:43:30 -04:00
Slava Pestov
af78807313 Sema: Generalize @_opaqueReturnTypeOf syntax to correctly handle parameter packs
We now allow the dummy identifier to be a qualified reference, so
that we can reconstruct generic parameter lists from multiple levels:

    @_opaqueReturnTypeOf(...) __.<OuterArgs...>.__<InnerArgs...>

This fixes an ambiguity with parameter packs, where flattening the
packs from multiple levels of nested types no longer produced an
unambiguous result.

To maintain backward compatibility, we still accept the old "flat"
form when no parameter packs are present.
2025-09-12 15:43:30 -04:00
Allan Shortlidge
13d61b0709 Frontend: Require -language-mode option when emitting swiftinterfaces.
If a `.swiftinterface` file does not include an explicit `-language-mode`
option (or its predecessor `swift-version`) and needs to be built as a
dependency of a client compilation, then the invocation to build the module
from interface would end up inheriting the language mode that the client code
is built with. This can result in spurious type checking diagnostics or even
mis-compilation. To ensure that a module interface is always built using the
language mode that its source code was originally built with, require an
explicit `-language-mode` option when emitting swiftinterface files.

Resolves rdar://145168219.
2025-09-12 09:10:23 -07:00
Allan Shortlidge
b047396246 AST: Use availability to control decl visibility in public swiftinterfaces.
Declarations that are unavailable at runtime because of an `@available`
attribute referencing a custom domain that was imported `@_spiOnly` should be
hidden from public swiftinterface files in `-library-level=api` modules. For
remaining declarations that do get printed in the public swiftinterface, skip
printing any `@available` attribute that refers to the domains from those
`@_spiOnly` dependencies. This allows API developers to control declaration
visibility using availability defined by another module.

Resolves rdar://156512028.
2025-09-04 12:32:19 -07:00
Allan Shortlidge
a5a49aaab6 ModuleInterface: Stop printing $CustomAvailability guards in swiftinterfaces.
All supported compilers can now parse `@available` attributes that reference
custom availability domains.
2025-09-04 09:12:27 -07:00
Allan Shortlidge
441132426f ModuleInterface: Only print API-level property wrappers in swiftinterfaces.
When a function parameter has attached property wrappers (SE-0293) those
property wrappers are either considered "implementation" or "API" level.
Property wrappers that are implementation-level don't affect how the function
is called and therefore shouldn't be included in swiftinterfaces unless the
function's body is also printed.

Resolves rdar://156711817.
2025-08-27 21:35:20 -07:00
Allan Shortlidge
79373e30bd Tests: Update the nsmanaged-attr.swift test for the Xcode 26 SDKs.
Something has changed about the CoreData module and caused the declarations in
this test interface to now be printed with `nonisolated` modifiers.

Resolves rdar://158783868.
2025-08-22 13:21:35 -07:00
Pavel Yaskevich
a7ecd309d4 [AST] SE-0487: Promote NonexhaustiveAttribute to a language feature
The proposal [has been accepted](https://forums.swift.org/t/accepted-se-0487-nonexhaustive-enums/81508)
which makes the feature experimental no longer.
2025-08-20 00:39:51 -07:00
Allan Shortlidge
5d3d93478a Frontend: Inherit compiler debugging options during module interface actions.
When building a module interface for the -typecheck-module-from-interface or
-compile-module-from-interface actions, inherit and honor compiler debugging
options and emit debugging output at the end of the interface build.
2025-08-12 15:48:42 -07:00
Alexis Laferrière
2ae485a6fd Merge pull request #83246 from xymus/cxx-swiftmodules
Serialization: Consider C++ interop use in module cache hash, preventing collisions
2025-08-05 09:33:21 -07:00
Alexis Laferrière
f8d6bedfae Serialization: Consider the C++ interop use in module cache hash
It is expected to rebuild modules from swiftinterface when the C++
interop is enabled in clients. The swiftmodule produced is different.
Make sure the rebuilt module is kept under a distinct cache key to avoid
reusing previously compiled modules in an incompatible mode.
2025-08-01 16:39:28 -07:00
Allan Shortlidge
2b8ab7fbab AST: Re-baseline SendingArgsAndResults feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
a37ce9a543 AST: Re-baseline IsolatedDeinit feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
71a5d9bd74 AST: Re-baseline ValueGenericsNameLookup feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
1d9e085197 AST: Re-baseline NonescapableTypes feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
dd28a3e4b5 AST: Re-baseline IsolatedAny feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
49dcbb7ad4 AST: Re-baseline BitwiseCopyable2 feature. 2025-07-31 10:21:55 -07:00
Allan Shortlidge
d09e117dc0 AST: Canonicalize platform versions for @backDeployed attrs.
Also, diagnose invalid platform versions.

Part of rdar://155558161.
2025-07-14 16:40:16 -07:00
Allan Shortlidge
910989c2c2 AST: Store parsed version in OriginallyDefinedInAttr instead of canonical.
Canonicalize the version on-demand instead.

NFC, part of rdar://155558161.
2025-07-14 16:04:04 -07:00
Allan Shortlidge
c6dad96492 Make LayoutPrespecialization a baseline feature instead of experimental.
Since LayoutPrespecialization has been enabled by default in all compiler
invocations for quite some time, it doesn't make sense for it to be treated as
experimental feature. Make it a baseline feature and remove all the
checks for it from the compiler.
2025-07-10 11:25:28 -07:00
Pavel Yaskevich
43eec8fede [AST/Sema] SE-0487: Expand @nonexhaustive attribute to support warn argument
The spelling `@nonexhaustive(warn)` replaces `@preEnumExtensibility`
attriubte.
2025-07-04 10:20:25 -07:00
Pavel Yaskevich
fe1ae75711 [AST/Sema] SE-0487: Rename @extensible into @nonexhaustive
This is an accepted spelling for the attribute. This commit
also renames the feature flag from `ExtensibleAttribute` to
`NonexhaustiveAttribute` to match the spelling of the attribute.
2025-07-03 17:50:05 -07:00
Andrew Trick
1a2d8e48fe Promote feature NonescapableAccessorOnTrivial to be non-experimental
This flag was not experimental for any good reason; it should always be
enabled. The flag only exists so we can introduce a new API:
UnsafeMutablePointer.mutableSpan. Supported compilers cannot handle the new API.

rdar://154247502 (Promote feature NonescapableAccessorOnTrivial to be
non-experimental)
2025-06-24 18:51:18 -07:00
Andrew Trick
cc357f4f32 Add Feature: NonescapableAccessorOnTrivial
To guard the new UnsafeMutablePointer.mutableSpan APIs.

This allows older compilers to ignore the new APIs. Otherwise, the type checker
will crash on the synthesized _read accessor for a non-Escapable type:

    error: cannot infer lifetime dependence on the '_read' accessor because 'self'
    is BitwiseCopyable, specify '@lifetime(borrow self)'

I don't know why the _read is synthesized in these cases, but apparently it's
always been that way.

Fixes: rdar://153773093 ([nonescapable] add a compiler feature to guard
~Escapable accessors when self is trivial)
2025-06-20 15:59:13 -07:00
Cyndy Ishida
64168edbf5 [Modules] Allow implicit conversions when loading interfaces with invalid os versions (#82228)
Initially, the compiler rejected building dependencies that contained OS
versions in an invalid range. However, this happens to be quite
disruptive, so instead allow it and request that these versions be
implicitly bumped based on what `llvm::Triple::getCanonicalVersionForOS`
computes.

resolves: rdar://153205856
2025-06-16 12:46:32 -07:00
Allan Shortlidge
e358cd6309 Tests: Correct invalid platform versions in @available attributes. 2025-06-10 22:11:05 -07:00
Allan Shortlidge
3f305a48c8 AST: Re-map macOS 16 aligned availability versions to 26.
- watchOS 12 -> 26
- visionOS 3 -> 26
- macos 16 -> 26
- iOS 19 -> 26
- tvOS 19 -> 26

The version numbers for `if #available(...)` queries are intentionally not
re-mapped.
2025-06-10 22:11:05 -07:00
Meghana Gupta
44e05fa858 [NFC] Update tests and diagnostics 2025-06-07 12:49:01 -07:00
John McCall
237e617fab Merge pull request #82008 from rjmccall/dont-copy-print-options
Prevent PrintOptions from being implicitly copied
2025-06-06 17:06:02 -04:00
Slava Pestov
0b3fd9eede ASTPrinter: Fix printing of let properties inside @objc @implementation extensions
A `let` here is really just a `var` with a `{ get }`.

Fixes rdar://problem/127120469.
2025-06-05 23:07:04 -04:00
John McCall
b3493bfa23 Prevent PrintOptions from being implicitly copied.
NFC *except* that I noticed a bug by inspection where we suppress
`@escaping` when print enum element types. Since this affects
recursive positions, we end up suppressing `@escaping` in places
we shouldn't. This is unlikely to affect much real code, but should
still obviously be fixed.

The new design is a little sketchy in that we're using `const` to
prevent direct use (and allow initialization of `const &` parameters)
but still relying on modification of the actual object.  Essentially,
we are treating the `const`-ness of the reference as a promise to leave
the original value in the object after computation rather than a
guarantee of not modifying the object. This is okay --- a temporary
bound to a `const` reference is still a non-`const` object formally
and can be modified without invoking UB --- but makes me a little
uncomfortable.
2025-06-05 12:52:01 -04:00
Pavel Yaskevich
e1e9f04398 Merge pull request #81863 from xedin/using-for-default-isolation-in-file-context
[AST/Sema] SE-0478:  Implement `using` declaration under an experimental flag
2025-06-02 09:56:29 -07:00
Pavel Yaskevich
c246a7a372 [AST/Sema] Hide using declaration behind DefaultIsolationPerFile experimental feature 2025-05-31 10:49:50 -07:00
Pavel Yaskevich
ad71e07cae [AST] Don't print using declarations in swift interfaces
These declarations are effectively `fileprivate` at the moment
and should appear in swift interfaces.
2025-05-31 10:49:50 -07:00
Anthony Latsis
0a1b8b0d50 [test] Fix misspelled FileCheck directives 2025-05-29 15:09:36 +01:00
Jan Svoboda
35e4fa8cf2 [ModuleInterface] Ignore SDKSettings.json in "sourceFiles" 2025-05-21 10:03:09 -07:00