Commit Graph

1231 Commits

Author SHA1 Message Date
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 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
Anthony Latsis 85db41932d Switch ASTContext::isLanguageModeAtLeast to LanguageMode 2026-02-10 16:06:58 +00:00
Kavon Farvardin d49ebd5a58 Merge pull request #87066 from kavon/supp-assoc-interfaces
SuppressedAssociatedTypesWithDefaults: swiftinterface and mangling support
2026-02-10 03:04:16 -08:00
Kavon Farvardin 1c8b03557c SuppAssocDefaults: extra mangling test coverage 2026-02-09 17:16:47 -08:00
Kavon Farvardin b2e698ec41 SuppAssocDefaults: update getRequirementsWithInverses
Given that we implicitly expanded Copyable & Escapable
conformance requirements for suppressed primary associated
types, we now need this function to do the opposite;
filtering Copyable & Escapable requirements on such primary
associated types and adding inverses if those requirements
are missing.

This function plays a crucial role in emitting the interface
files accurately for functions and types, in addition to
how we mangle generic signatures into function symbols.

The mangling for generic signatures under the -WithDefaults version of
suppressed associated types goes like this:

- primary associated type T.A has an inverse `Rj` or `RJ` mangled
  into the generic signature if it lacks the conformance, or
  nothing is mangled into it.

- non-primary associated type T.B has either a `T.B: Copyable`
  requirement mangled into it, or nothing is mangled into it.

For the legacy SuppressedAssociatedTypes feature, where there's no
defaults, it uses the "non-primary assocated type" mangling strategy
for all generic signatures.
2026-02-09 16:10:00 -08:00
Andrew Trick e9312d3d10 Merge pull request #87055 from atrick/lifedep-inout-defaults
Tweak lifetime dependencies for 'inout' parameters
2026-02-09 08:40:45 -08:00
Kavon Farvardin 3021f32c9b Merge pull request #87048 from kavon/retro-refinement-3
Reparenting: second batch of fixes
2026-02-06 19:04:04 -08:00
Andrew Trick d4b0c713d4 Tweak lifetime dependencies for 'inout' parameters
Assume a default dependency for all 'inout' parameters regardless of the
presence of an explicit annotation.

Default to `@lifetime(inoutArg: copy inoutArg)` even if an explicit annotation
exists.

This way API authors do not need to make the inout dependency explicit when they
probably always want that and don't normally need to write it.

Now:
```
@_lifetime(a: copy b)
func foo(a: inout T, b: T)
```

implies:
```
@_lifetime(a: copy a, copy b)
func foo(a: inout T, b: T)
```

Fixes rdar://169835235 (Always default inout dependencies)
2026-02-06 16:11:26 -08:00
Kavon Farvardin 58ad64d3f4 Reparenting: fix interface emission
The `@reparented` was missing and a typealias
was being synthesized unexpectedly, creating
an issue when typechecking the interface later.

There's no fundamental reason why typealiases
cannot be supported to say the same thing as
the same-type requirement, but I think the
same-type requirement is always needed to be
written on the extension, one way or another.

For now I've chosen to only go with an
explicitly-written same-type requirement.
2026-02-06 13:23:22 -08:00
Aidan Hall e98a7a6bf8 Merge pull request #86842 from aidan-hall/just-func-type-lifetimes-try-print
LifetimeDependence: Support function types
2026-02-06 10:09:25 +00:00
Ian Anderson 4d89b9b0a5 Merge pull request #86945 from ian-twilightcoder/case-sensitive-test-fix
[test][NFC] ModuleInterface/canonicalized-os-version.swift fails on a case sensitive file system
2026-02-05 20:26:29 -08:00
Pavel Yaskevich 527ab6386a Merge pull request #86967 from xedin/rdar-164077275
[Concurrency] A few fixes for default isolation inference
2026-02-05 15:31:10 -08:00
Ian Anderson 61b0472662 [test][NFC] ModuleInterface/canonicalized-os-version.swift fails on a case sensitive file system
Fix a typo in the test
2026-02-05 15:29:45 -08:00
Aidan Hall 6aa55785f0 LifetimeDependence: Tests for function type attribute
Includes:
- rdar://166912068 test case
- Nested type SIL tests
- rdar://160894371 test
- Many more
2026-02-05 14:50:44 +00:00
Meghana Gupta 657fa172bc Fix ASTPrinting of borrow/mutate protocol requirements 2026-02-04 07:16:32 -08:00
Meghana Gupta a3a3134037 Guard borrow/mutate accessors in swiftinterface files 2026-02-04 07:16:28 -08:00
Pavel Yaskevich 9b8e53c0a1 [Concurrency] Check whether @preconcurrency is supported before adding it
Don't trasfer "preconcurrency" from isolation onto a declaration if
the declaration doesn't support it. This is especially important for
`MainActor` by default mode where each `@MainActor` injection site
gets marked as `@preconcurrency` implicitly in pre-6 language modes.

Resolves: https://github.com/swiftlang/swift/issues/85564
2026-02-03 10:29:59 -08:00
Becca Royal-Gordon fce99b3173 Merge pull request #86859 from beccadax/mod-squad-not-for-export 2026-01-29 09:02:50 -08:00
Becca Royal-Gordon 71986c6559 Merge pull request #86862 from beccadax/mod-squad-aka-workaround 2026-01-29 09:02:00 -08:00
Sam Pyankov 1c2cb16a6a ASTPrinter: skip printing incompatible attributes in swiftinterface
Attributes that can not appear on declaration should not be printed in textual interface
rdar://164975727
2026-01-28 15:48:21 -08:00
Becca Royal-Gordon d8f38cfa71 [ModuleInterface] Disable aliasing with selectors
When both `-alias-module-names-in-module-interface` and `-enable-module-selectors-in-module-interface` are turned on, the compiler now disables the former with a warning. Eliminates workaround hacks that should no longer be necessary.

Fixes rdar://problem/169132519.
2026-01-28 15:47:52 -08:00
Becca Royal-Gordon f02b2f1532 Use export_as name in some private swiftinterfaces
Previously, if a declaration belonged to a module with an `export_as` attribute, Swift always used the exported module name in the public module interface and the real module name in the private module interface. However, this is only a rough approximation of the behavior we really want, which is to use the real name in module interfaces that might be imported by dependencies of the exported name.

Change this logic so that public interfaces always use the exported name, and private interfaces use the exported name *only* if a module with that name has been loaded. This should make it so that if you’re building the `export_as` module or anything that imports it, you use the exported name; otherwise you use the real name.

Fixes rdar://167874630.
2026-01-28 14:28:14 -08:00
Becca Royal-Gordon a68d8176a8 [NFC] Tweak export_as test
Duplicated set of commands, FileCheck use pattern that produces suboptimal diagnostics.
2026-01-28 14:26:10 -08:00
Sam Pyankov 139c325d76 Merge pull request #86323 from slavapestov/fix-ppt-type-witness-conflict-crash
Sema: Fix crash when parameterized protocol types define conflicting type witnesses
2026-01-14 09:51:03 -08:00
Slava Pestov 38a9d8389d Sema: Fix crash when parameterized protocol types define conflicting type witnesses 2026-01-13 15:52:44 -08:00
Tim Kientzle adec1f6cbe Merge pull request #86277 from tbkka/tbkka-rdar149303951-try1
[SE-0474] Implement final `yielding borrow`/`yielding mutate` naming for coroutine accessors
2026-01-09 08:52:21 -08:00
Doug Gregor 3f00643d13 [Module interface printing] Print @c as @_cdecl for older compilers
Add a feature just for the purpose of suppressing it. Print the check
as `hasAttribute(c)` so this feature can be temporary.

Fixes rdar://167546897 .
2026-01-05 09:47:19 -08:00
Tim Kientzle 104dba920b [SE-0474] Implement yielding borrow and yielding mutate syntax
This does not rename all the internal variables, functions, and types
whose names were based on the old syntax.

I think it adds new syntax support everywhere it's needed while
retaining enough of the old syntax support that early adopters will
see nice deprecation messages guiding them to the new syntax.
2026-01-03 15:07:10 -08:00
Becca Royal-Gordon ad7785713e Disable preserve-types when using module selectors
The old `-module-interface-preserve-types-as-written` workaround flag prevents module selectors from being printed into module interfaces even when they have been explicitly requested. Disable it and emit a warning when it’s used in combination with `-enable-module-selectors-in-module-interface`.

Fixes rdar://166237384.
2025-12-19 14:06:27 -08:00
Becca Royal-Gordon ef1470baed Don’t print module selectors in more cases
There were a number of cases where Swift would emit module selectors into module interface files that it was subsequently unable to parse because the compiler at least temporarily represented them as dependent member types. Modify the carve-out so that if *any* of a type’s parents are generic parameters or archetypes, we don’t print a module selector on it.

Fixes rdar://166180424.
2025-12-19 13:33:35 -08:00
Meghana Gupta 4089775de8 Fix swiftinterface printing of accessors and inferred lifetime dependencies when Lifetimes feature is enabled 2025-12-09 14:59:41 -08:00
Pavel Yaskevich b6291e680d Merge pull request #85736 from xedin/rdar-122963120
[ASTPrinter] Print a fully resolved type for an outermost property wr…
2025-12-02 11:54:53 -08:00
Pavel Yaskevich 4b33db0a84 Merge pull request #85605 from xedin/tilde-sendable-cond-conformances
[Concurrency] Allow conditionally conforming to `Sendable` when confo…
2025-12-01 21:53:25 -08:00
Pavel Yaskevich 5b665a8426 [ASTPrinter] Print a fully resolved type for an outermost property wrapper in swift interfaces
The type of an outermost property wrapper should be printed together
with (inferred) generic arguments because otherwise if a any wrapper
in the chain has generic parameters that are not involved in
`wrappedValue:` argument it won't be impossible to infer them while
type-checking the interface file where it appears.

Resolves: rdar://122963120
2025-11-28 22:00:14 -08:00
Sam Pyankov 7c8766fac8 Merge pull request #85571 from sepy97/desugar-inherited-ParaProtoType
ModuleInterface: Avoid printing generic arguments of a ParameterizedProtocolType in inheritance clause
2025-11-20 18:29:52 -08:00
Pavel Yaskevich d868e68cd2 [Concurrency] Allow conditionally conforming to Sendable when conformance is suppressed
For consistency with invertible protocols using `~Sendable` should
only prohibit use of unconditional extensions.

For example:

```swift
struct G<T>: ~Sendable {}
```

The following (unconditional) extension is rejected:

```
extension G: Sendable {} // error: cannot both conform to and suppress conformance to 'Sendable'
```

But conditional on `T` is accepted:

```
extension G: Sendable where T: Sendable {} // Ok!
```
2025-11-19 16:46:29 -08:00
Sam Pyankov 480b64ef50 ModuleInterface: Avoid printing generic arguments of a ParameterizedProtocolType in inheritance clause
When emitting module interfaces, parameterized protocols in inheritance clauses were being printed with generic arguments (public struct T: Fancy<Float64>), causing errors with protocol conformance verification.
The fix strip ParameterizedProtocolType to its base protocol type when printing inherited types, producing the correct inheritance clause.

Resolves: rdar://161925627
2025-11-19 10:27:15 -08:00
Arnold Schwaighofer 91991bfd47 Silence Misc/verify-swift-feature-testing.test-sh failure 2025-11-07 10:46:33 -08:00
Arnold Schwaighofer 9795f65145 Change tests to also test that this feature is available per default 2025-11-07 10:10:47 -08:00
Becca Royal-Gordon 2504beeccc Merge pull request #85043 from beccadax/mod-squad-interface
[SE-0491] Conditionally emit module selectors into swiftinterfaces
2025-11-03 19:08:09 -08:00
Artem Chikin 164d3ae5a8 Merge pull request #85010 from artemcm/AlwaysRebuildExplicitInterface
[Explicit Module Builds] Always rebuild the target module in explicit `-compile-module-from-interface` builds.
2025-10-31 21:24:18 -04:00
Becca Royal-Gordon 9454c0aaa4 Emit module selectors in swiftinterfaces
This support is currently opt-in and can be disabled by a blocklist.
2025-10-31 16:48:06 -07:00
Alexis Laferrière 94113f4a83 SE-496: Remove references to features CDecl and CImplementation 2025-10-29 17:31:20 -07:00
Artem Chikin 4cdbcb8645 [Explicit Module Builds] Always rebuild the target module in explicit -compile-module-from-interface builds.
We have long switched to delegate the checking of whether a module is up-to-date to the build system (SwiftDriver) and stopped serializing file dependencies for interface-built binary modules.

Resolves rdar://162881032
2025-10-20 14:13:37 -07:00
Joe Groff 25af94495c Merge pull request #84975 from jckarter/cant-discard-in-inlinable-code
Sema: `discard self` should not be allowed in inlinable methods of non-frozen types.
2025-10-20 08:28:38 -07:00
Rintaro Ishizaki 13e17870cc Merge pull request #84972 from rintaro/accessor-disambiguation-rdar140943107
[ASTPrinter/Parse] Disambiguate accessor block in .swiftinterface
2025-10-17 18:40:56 -07:00
Joe Groff 6f2811110d Sema: discard self should not be allowed in inlinable methods of non-frozen types.
`discard self` requires knowledge of the internal layout of the type in order to clean
up its fields while bypassing its public `deinit`. Inlinable code can get copied into
and run from outside of the defining module, so this is impossible to implement.
Fixes rdar://160815058.
2025-10-17 16:14:58 -07:00