Commit Graph

1278 Commits

Author SHA1 Message Date
Allan Shortlidge de35fbd4ff AST: Add the UnsupportedScopedImport diagnostic group. 2026-04-23 15:28:09 -07:00
Allan Shortlidge 091d1dad64 Sema: Skip MemberImportVisibility diags for conformances in swiftinterfaces.
Conformance checking in swiftinterfaces is lenient and can recover from missing
witnesses by assuming that the protocol witness table will have an entry for
the requirement at runtime. As a result, diagnosing missing imports for
witnesses here could break source compatibility for existing interface files
and must be skipped. This fixes a regression introduced by
https://github.com/swiftlang/swift/pull/88470.

Resolves rdar://175215763.
2026-04-22 16:28:55 -07:00
Tim Kientzle c46cabde95 Merge pull request #88504 from tbkka/tbkka-yielding-in-swiftinterface
Write `yielding` accessor names to swiftinterface files
2026-04-19 13:35:54 -07:00
Doug Gregor d31c82ce95 Merge pull request #88446 from DougGregor/code-generation-model
Aggressive CMO can force the serialization of the bodies of `@export(interface)` functions
2026-04-16 10:01:08 -07:00
Allan Shortlidge 902f13a132 AST: Add group IDs to diags for module interface option obsoletion..
Makes it possible for users of `-warnings-as-errors` to control the behavior of
warnings about the obsoletion of module interface emission options.

Resolves rdar://174787052.
2026-04-15 13:08:31 -07:00
Doug Gregor f2eb7cb1a8 [SIL] Model @export(interface) and @export(implementation) on SIL functions
The `@export(interface)` and `@export(implementation)` attributes
SE-0497 are queried directly on AST nodes in several places within the
SIL pipeline. However, they don't persist when SIL functions are
serialized, meaning that clients of the original module might make
different assumptions about the availability of a given function's
definition.

Represent these attributes in a SIL function (as an optional
CodeGenerationModel), (de-)serialize them into the module, and add a
textual representation as SIL function attributes `[export_interface]`
and `[export_implementation]`.
2026-04-15 13:04:10 -07:00
Tim Kientzle c85ebdaed5 Write yielding accessor names to swiftinterface files
Back in January, I updated the swiftinterface _reading_ code to accept either
`read`/`modify` or `yielding borrow`/`yielding mutate`.  That update has been
around for long enough that we can now switch over the swiftinterface _writing_
code to emit the standard final `yielding borrow`/`yielding mutate` spellings.

Interface files written with the old spellings will continue to be
accepted for some time (likely a year or more).
2026-04-15 12:34:46 -07:00
Saleem Abdulrasool 2b8ee6e5a2 test: disallow llvm-bcanalyzer and use new macro
This ensures that we use the correct llvm-bcanalyzer from the just built
compiler tools.
2026-04-13 16:22:02 -07:00
Kavon Farvardin f608fc03ef Reparenting: even more feature guarding improvements
The only known condfail scenario is inheriting from
a protocol P that inherits from a reparentable one R.

We already guard P if it mentions R in its inheritance clause.
So older compilers will simply report that "P" is missing in the
interface, which is a better error message than virally guarding
everything mentioning P. It's an ABI break anyway to do that
without introducing a `@reparented` extension, which needs a guard.

In theory, older compilers shouldn't have too much go wrong if they
were to ignore `@reparentable`, though the RequirementMachine and
witness tables will look different.

rdar://174263176
2026-04-08 10:48:40 -07:00
Allan Shortlidge 102581b597 ModuleInterface: Handle more synthesized conformance availability corner cases.
As a follow up to https://github.com/swiftlang/swift/pull/87832, continue
adjusting the algorithm for computing synthesized conformance availability.
When an outer declaration is `unavailable` in a more specific platform domain
and the inner declaration is `introduced:` in a less specific domain, the inner
declaration attribute does not override the outer declaration attribute.
Unavailability and introduction on separate axes of availability.

Resolves rdar://173724423.
2026-03-30 17:42:39 -07:00
Meghana Gupta 3d3d476b6f Merge pull request #88107 from meg-gupta/enableborrow
Enable BorrowAndMutateAccessors by default
2026-03-27 12:43:02 -07:00
Allan Shortlidge 141ac3fd5d Merge pull request #88079 from tshortli/unowned-executor-availability
Sema: Removed inferred availability from `unownedExecutor` synthesis
2026-03-25 19:06:59 -07:00
Meghana Gupta d6e220669f Enable BorrowAndMutateAccessors by default 2026-03-25 16:52:39 -07:00
Allan Shortlidge 9d2d1a3316 Sema: Removed inferred availability from unownedExecutor synthesis.
The compiler synthesizes an `unownedExecutor` property for every `actor` type.
It was also synthesizing availability attributes for this property by
intersecting the availability of the actor type and the `UnownedExecutor` type.
This may have been necessary early in the development of Swift Concurrency but
now it amounts to little more than a convoluted procedure that must result in
repeating the availability of the actor on one of its properties (the property
can never be less available than the actor itself).
2026-03-25 04:54:25 -07:00
Allan Shortlidge 945f95f8d4 ModuleInterface: Improve availability inference for synthesized conformances.
When printing `.swiftinterface` files, implicit conformances may need to be
printed with inferred availability attributes. The existing algorithm for
determining which availability attributes to print needed a few updates to
better handle `anyAppleOS` availability attributes:

- `@available(anyAppleOS, ...)` attributes attached to a nested declaration
  should take priority over platform-specific `@available` attributes on outer
  declarations.
- At the same time, `@available(anyAppleOS, ...)` attributes attached to the
  _same_ declaration as a platform-specific `@available` attribute should not
  take priority. Instead, both attributes should be included in the inferred
  set.
2026-03-25 04:51:42 -07:00
Steven Wu 12f8d9c6c9 [TEST] Switch to use new swift-driver when running tests
Default to use new swift-driver to run lit tests as legacy swift driver
is deprecated for a long time. The lit tests for legacy drivers are also
disable when running new swift-driver.

Tests that relies on legacy swift driver (for example, tests merge
module) can be enabled on conditions `legacy_swift_driver`. Fix and
split up some existing tests that relies on legacy driver.
2026-03-23 09:48:45 -07:00
Pavel Yaskevich de8b2fb22c [Frontend] SE-0518: Turn TildeSendable into a language feature
The proposal has been accepted and `~Sendable` doesn't require
an explicitly enabled experimental flag.
2026-03-20 10:27:12 -07:00
Steven Wu 3ba1ba45d4 Merge pull request #87892 from cachemeifyoucan/eng/PR-172693314
[DependencyScan] Propagate module library level through dependency scanner for CAS builds
2026-03-18 09:08:27 -07:00
Aviva Ruben 2f58b7c57a [Sema] Preserve type alias sugar when removing escaping
This change fixes rdar://172417385 and #45125 by using transformRec
to set no escape, instead of casting which drops sugar. This affects
how interfaces are printed, and could theoretically cause issues with
printing private aliases into public interfaces. Motivated by needing
to be able to diagnose issues with attributes on aliases; without this
change, the alias sugar is sometimes lost.
2026-03-17 11:33:58 -07:00
Steven Wu 34d52cfe1a [DependencyScan] Propagate module library level through dependency scanner for CAS builds
Compute and propagate the library level (api/spi/ipi) of each module
dependency through the dependency scanner so that the compiler can
correctly enforce private module import diagnostics in CAS mode, where
path-based SPI detection fails because CAS abstracts file paths to
content IDs.

Swift modules:
- Detect library level from the module interface path using
  libraryLevelFromPath() during scanning, for both textual (.swiftinterface)
  and binary (.swiftmodule) Swift modules.

Clang modules:
- Expose ModuleMapIsPrivate from clang::Module in ModuleDeps via the
  dependency scanning infrastructure.
- Set library level for clang modules in bridgeClangModuleDependency()
  using ModuleMapIsPrivate (catches module.private.modulemap in any
  SDK location) and libraryLevelFromPath() on the module map file
  (catches modules under PrivateFrameworks directories).

The library level is:
- Stored in ModuleDependencyInfo and serialized in the module dependency
  cache (format version bumped to v8).
- Exposed through the swiftscan C API via a new
  swiftscan_module_info_get_library_level() function (API minor version
  bumped to 3).
- Emitted in the dependency scanner JSON output as "libraryLevel" for
  all module kinds (Swift textual, Swift binary, Clang, and main module).
- Parsed from the explicit module map JSON by ExplicitModuleMapParser
  for both Swift (ExplicitSwiftModuleInputInfo) and Clang
  (ExplicitClangModuleInputInfo) modules.
- Looked up in ModuleLibraryLevelRequest via
  ASTContext::getExplicitModuleLibraryLevel(name, isClang), which
  consults the appropriate map (Swift or Clang) based on module kind.

rdar://172693314

Assisted-By: Claude
2026-03-17 11:04:18 -07:00
Allan Shortlidge c875d52cdd Merge pull request #87821 from tshortli/reorder-platform-kinds
AST: Reorder platforms in `PlatformKinds.def`
2026-03-12 10:37:33 -07:00
Allan Shortlidge 9cfdb17d7e AST: Reorder platforms in PlatformKinds.def.
This allows stable sorting of availability domains to result in an order that
looks more natural when printed in swiftinterface files.
2026-03-12 01:50:31 -07:00
Kavon Farvardin 8f8b782531 Merge branch 'main' into se427-techdebt 2026-03-11 10:00:18 -07:00
Kavon Farvardin e5b2ead0d7 Sema: remove SE427NoInferenceOnExtension
The feature was added only to avoid a reverse-condfail
in the initial bring-up of noncopyable generics.

Nearly 2 years have passed since the last time I tried
to remove this old technical debt [1] and had to revert
it due to outdated build bots [2]. Hoping that won't be
a problem this time.

[1] 5b2f2cbfcf
[2] https://github.com/swiftlang/swift/pull/75267

resolves rdar://131560183
2026-03-11 09:57:47 -07:00
Allan Shortlidge bac99b6d63 Merge pull request #87779 from tshortli/revert-87670
Revert "ModuleInterface: Fix availability attributes on synthesized conformances
2026-03-11 06:00:50 -07:00
Kavon Farvardin 745cc5a4b0 Merge pull request #87791 from kavon/polish-suppassoc 2026-03-11 01:20:19 -07:00
Kavon Farvardin fe50668d0e SuppAssocTypes: add deprecation warning of legacy version
We need to start moving people over to using the version of
suppressed associated types that has the officially accepted
behavior according to SE-503, and that is via
`SuppressedAssociatedTypesWithDefaults`.

To allow for time to migrate to the new version, I'm introducing
the deprecation message as a warning for now.

This set of changes also moves most of the test suite over to using
the officially accepted version.

rdar://172231663
2026-03-10 17:08:10 -07:00
Allan Shortlidge a2a120daab Revert "ModuleInterface: Fix availability attributes on synthesized conformances."
This reverts commit 457debcf4d.

Resolves rdar://172144339.
2026-03-10 14:27:11 -07:00
Rintaro Ishizaki f8911bc257 [ASTPrinter] Disambiguation marker for simple-stored var accessor block
Previously, the `@_accessorBlock` disambiguation attribute was only
emitted for observed variables. But We need `@_accessorBlock`
disambiguation marker for simple stored properties with non-public
setters in `@frozen` types too.

rdar://171819084
2026-03-05 14:14:41 -08:00
Allan Shortlidge 457debcf4d ModuleInterface: Fix availability attributes on synthesized conformances.
Adjust the algorithm that collects the availability attributes for synthesized
conformances to ensure it skips attributes from parent declarations that are
superceded by attributes in nested declarations, even when the domains of those
attributes do not match exactly.
2026-03-03 17:14:45 -08:00
Allan Shortlidge c7ce5a8aed Parse: Allow availability macros to contain empty expansions.
In some cases, it's useful to allow an availability macro to expand to an empty
availability specification list. Allow developers to express this using macros
that are defined to exactly the string `*`, while continuing to reject `*` in
availability macros that contain other entries.
2026-03-02 12:14:29 -08:00
Allan Shortlidge bee3eb843b ModuleInterface: Handle custom availability domains for synthesized conformances.
When gathering availability attributes to print in a .swiftinterface for
synthesized conformances to inherited protocols, don't assume availabilty
attributes always have a platform kind.

Resolves rdar://170361240.
2026-02-28 17:56:41 -08:00
Allan Shortlidge 864c08f5ef Merge pull request #87501 from tshortli/require-language-mode-in-interface
Frontend: Require explicit language mode when emitting swiftinterfaces
2026-02-25 21:35:05 -08:00
Sam Pyankov 87421450a5 Merge pull request #87434 from sepy97/transitive_import_check
ASTPrinter: Filter inherited constructors from restricted modules
2026-02-25 20:50:23 -08:00
Allan Shortlidge 1ca0d87e2b 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 #84307 this diagnostic was downgraded to a warning. The failures it caused
in PR testing should now be resolved.

This is a re-attempt of https://github.com/swiftlang/swift/pull/84327.

Resolves rdar://145168219.
2026-02-25 12:42:02 -08:00
Sam Pyankov 2aeaf2cd89 ASTPrinter: Filter inherited constructors from restricted modules
Skip printing inherited constructors defined in modules that are not
publicly imported.
This prevents interface verification errors where types are used but
their modules aren't in the import list.

rdar://168101765
2026-02-25 11:36:32 -08:00
Ryan Mansfield f07c1a1b82 Merge pull request #87284 from rjmansfield/se-0441-alias-swap
Swap the alias relationship between -language-mode and -swift-version.
2026-02-20 18:14:44 -05:00
Becca Royal-Gordon 1f008fb0d0 [ModuleInterface] Enable module selectors by default
And update tests to use them.

This commit depends on fixes in swiftlang/swift PRs #86905, #87129, and #87130.

Fixes rdar://169749886.
2026-02-20 00:35:23 -08:00
Ryan Mansfield ae78773ad8 Swap the alias relationship between -language-mode and -swift-version.
As specified in SE-0441, -language-mode should appear in help output
while -swift-version should be the hidden alias.

Related to swiftlang/swift-driver#1894
2026-02-18 16:06:08 -05:00
Aidan Hall 229eccb899 Merge pull request #87183 from aidan-hall/lifedep-borrow-print
LifetimeDependence: Fix mutable borrow printing
2026-02-16 10:12:35 +00:00
Becca Royal-Gordon 3dc9fba08e Merge pull request #87128 from beccadax/mod-squad-dissociated
[ModuleInterface] Fix associated type selectors more
2026-02-12 23:04:55 -08:00
Aidan Hall a8c5a0cc92 LifetimeDependence: Fix mutable borrow printing
Use the '&' specifier for inout scoped dependence sources, since this is the
only kind of borrowed dependence they can have.
2026-02-12 17:29:56 +00:00
Andrew Trick 0867ca8ec4 Merge pull request #87101 from atrick/lifedep-inout-immortal
Support @_lifetime(immortal) to suppress inout default dependency
2026-02-12 09:09:31 -08:00
Pavel Yaskevich 88c0b0adcb Merge pull request #87096 from xedin/rdar-166159992
[ASTPrinter] Print `Sendable` conformance for package types in swift …
2026-02-11 12:20:03 -08:00
Andrew Trick b7e2186f7d Support @_lifetime(immortal) to suppress inout default dependency
Non-Escapable 'inout' arguments have a default self-dependency, regardless of
any other annotations.  For example:

    @_lifetime(dest: copy source)
    /* DEFAULT: @_lifetime(dest: copy dest, copy source) */
    func foo<T: ~Escapable>(dest: inout T, source: T)

An immortal lifetime specifier now suppresses that default. For example:

    @_lifetime(dest: immortal, copy source)
    /* DEFAULT: @_lifetime(dest: copy source) */
    func foo<T: ~Escapable>(dest: inout T, source: T)

This is necessary because there is otherwise no other way to suppress the
default lifetime.

Fixes rdar://170016708 ([nonescapable] Support @_lifetime(immortal) to suppress
the usual inout default self-dependency)
2026-02-11 05:55:26 -08:00
Becca Royal-Gordon b0bd6c711c Merge pull request #86905 from beccadax/mod-squad-not-for-export-2 2026-02-11 02:28:08 -08:00
Becca Royal-Gordon 31ef4d00e0 [ModuleInterface] Fix associated type selectors more
Qualification has discovered a complicated test case where the module interface printer incorrectly adds module selectors to nested types that don’t support them. Tweak module interface printing to omit the module selector in more situations.

Fixes rdar://169720990.
2026-02-10 16:43:21 -08:00
Becca Royal-Gordon cbad1d8a18 Tweak export_as behavior with submodules
In #86859, I modified the way `export_as` names are used in private module interfaces so that the `export_as` name is used when that module has been imported. This turns out to be slightly too aggressive in a specific scenario where a submodule of the export_as module imports a submodule of the real module—the compiler ends up using the export name even though the resulting lookup won’t actually work.

Modify the logic for deciding whether to use an exported module name so that it not only checks whether the export_as module has been loaded, but also whether the specific module or submodule the declaration belongs to is (possibly transitively) imported by that module.

Fixes rdar://167874630 (harder).
2026-02-10 15:49:47 -08:00
Kavon Farvardin 0a74877ec3 Merge pull request #87119 from kavon/supp-assoc-interfaces-2
SuppAssocDefaults: extra mangling test coverage
2026-02-10 14:13:42 -08:00
Anthony Latsis 4cdd2955a9 Merge pull request #86956 from swiftlang/jepa-main
Basic: Introduce a safe, structured representation for language modes
2026-02-10 21:03:03 +00:00