Commit Graph

4367 Commits

Author SHA1 Message Date
Hamish Knight
bc65846be2 [Sema] SE-0502: Enable ExcludePrivateFromMemberwiseInit by default
Enable the feature by default, and add an experimental feature
`DeprecateCompatMemberwiseInit` to control the deprecation behavior
which was deferred from the proposal.
2026-02-06 11:50:40 +00: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
Artem Chikin
e168a84355 Merge pull request #86980 from jamieQ/fix-diag-control-bug
[Diagnostics]: restore unknown warning group behavior
2026-02-05 18:59:27 +00:00
Aidan Hall
805d8e9e26 Add language feature ClosureLifetimes 2026-02-05 14:50:14 +00:00
Ian Anderson
6f9919edc1 Merge pull request #86906 from ian-twilightcoder/firmware-os
[Triple] Support the new target triple "os" for firmware
2026-02-04 12:15:56 -08:00
Jamie
94eab75e86 [Diagnostics]: restore unknown warning group behavior 2026-02-04 08:15:49 -06:00
Slava Pestov
437589d1b6 Merge pull request #86950 from slavapestov/remove-more-solver-hacks
Sema: Add flag to disable more solver performance hacks
2026-02-04 08:13:31 -05:00
Kavon Farvardin
4a7cedcf1e Reparenting: introduce new attributes
A protocol that's been reparented declares it
by writing `@reparented` in its inheirtance clause
for each new parent. You can introduce a `@reparented`
parent to a pre-existing ABI-stable protocol's
inheritance hierarchy.

Only protocols declared to be  `@reparentable` can be
used to reparent other protocols. Adding or removing
the `@reparentable` attribute is ABI-breaking, as it
effects the type metadata layout. Thus, reparentable
protocols must be born as such to use them with
protocols that are already ABI-stable.

This set of changes does not include the actual
implementation of ABI-stable reparenting.
2026-02-03 16:39:19 -08:00
Slava Pestov
9623b85b7b Parse: Remove last remnants of 'operator designated types' 2026-02-03 16:34:10 -05:00
Slava Pestov
2e60d29973 Sema: Add -solver-{disable,enable}-performance-hacks flags 2026-02-03 16:34:10 -05:00
Slava Pestov
061958f970 Sema: Eagerly filter out protocol extension operators
This optimizes for the case where we have a disjunction that contains an
operator defined in a protocol, and a protocol defined in a protocol
extension, and furthermore, the protocol extension operator's type is a
refinement of the protocol requirement operator's type.

In this case, there are three possibilities:

- Either the operator requirement is witnessed by a concrete operator
  in the conforming type, in which case the solution involving the
  protocol extension operator is going to be worse, so we can skip this
  choice.

- Otherwise, the protocol requirement operator is witnessed by the same
  protocol extension operator that we skipped, in which case we will find
  the same solution if we just pick the protocol requirement operator
  anyway.

- The only other possibility is that the protocol requirement operator
  is witnessed by a protocol extension operator, but also, a more
  refined protocol extension operator exists. However, it appears that in
  this case, solution ranking _also_ picks the solution involving the
  protocol requirement operator, as the new test case demonstrates.

Thus, we gain nothing by considering these protocol extension operators.
Skip them when forming the disjunction.
2026-02-03 16:34:09 -05:00
Ian Anderson
69fa949c01 [Triple] Support the new target triple "os" for firmware
Add support for the new Firmware llvm::Triple::OSType, and make a swift::DarwinPlatformKind to go with it.

rdar://165361368
2026-02-03 13:02:44 -08:00
Hamish Knight
0f968df26e Merge pull request #86791 from hamishknight/compat-hack
[CS] Add `for` loop compatibility hack for `makeIterator`/`next` ranking
2026-01-28 22:47:56 +00:00
Hamish Knight
1bff51d40d [AST] NFC: Introduce isAtLeastFutureMajorLanguageMode
And use it for clients checking for the next future major language mode.
2026-01-27 23:30:43 +00:00
Alexis Laferrière
fce039e841 Merge pull request #86794 from xymus/enable-recovery-from-broken-modules-by-default
Serialization: Enable recovery from broken modularization by default
2026-01-27 15:24:39 -08:00
Slava Pestov
0a6c34325a Frontend: Add -solver-enable-prune-disjunctions flag
Off while I work on this feature.
2026-01-26 21:48:59 +00:00
Alexis Laferrière
be0b7595fe Serialization: Enable recovery from types moving between modules by default 2026-01-26 09:56:30 -08:00
Slava Pestov
d860523944 Merge pull request #86760 from slavapestov/solver-shuffle
Sema: Add -solver-shuffle-disjunctions= and -solver-shuffle-choices= flags for debugging
2026-01-24 12:30:43 -05:00
Slava Pestov
30f1b0187a Sema: Add -solver-shuffle-disjunctions= and -solver-shuffle-choices= flags for debugging 2026-01-23 20:02:21 -05:00
Tim Kientzle
7e32732649 [SE-0474] Force unwind off for new yielding accessors
In the context of coroutine/yielding accessors, "unwind" means
that the second half of the coroutine (code _after_ the `yield`
statement) will not run if an exception is thrown during the access.

Unwinding was the default behavor for legacy `_read`/`_modify` coroutine
accessors.
For the new `yielding borrow`/`yielding mutate` accessors, unwinding
was optional behind a separate feature flag.
But the final SE-0474 dictates that unwinding is always _disabled_ for
the new yielding accessors.  That is, the new yielding accessors always
run to completion, regardless of whether there are thrown exceptions within
the access scope.  This was deemed essential to ensure that authors of
data structures could guarantee consistency.

This PR permanently disables unwinding behavior for the new accessors.
The feature flag still exists but has no effect.
A handful of tests that verified the unwinding behavior have been
edited to ensure that unwinding does _not_ happen even when the feature
flag is specified.
2026-01-23 16:01:48 -08:00
Doug Gregor
b47a2ab2e7 Merge pull request #86735 from DougGregor/embedded-dynamic-exclusivity-staging
[Embedded] Put dynamic exclusivity behind a second experimental feature
2026-01-23 02:21:17 -08:00
Doug Gregor
cc2fc8ae65 [Embedded] Put dynamic exclusivity behind a second experimental feature
We need to stage in the behavior change to enable dynamic exclusivity
checking for Embedded Swift. For now, ignore
`-enforce-exclusivity=checked` in Embedded Swift unless the
experimental feature `EmbeddedDynamicExclusivity` is also enabled.

Addresses rdar://168618037, a regression in Embedded Swift code that
is passing `-enforce-exclusivity=checked` explicitly.
2026-01-22 21:22:19 -08:00
Tim Kientzle
1594ad5c70 Merge pull request #86688 from tbkka/tbkka-yielding_borrow-Part3
Preparation for switching .swiftinterface to `yielding` terminology
2026-01-22 20:12:30 -08:00
Pavel Yaskevich
1e77e79af3 [Sema] Remove block action to enable constraint solver performance hacks 2026-01-21 12:54:51 -08:00
Pavel Yaskevich
b564e8c1bd [Frontend] Remove -enable-constraint-solver-performance-hacks frontend flag
This flag is obsolete and it doesn't have any users.
2026-01-21 11:56:06 -08:00
Tim Kientzle
1c2bd08c77 Preparation for switching .swiftinterface to yielding terminology
For now, we write `read`/`modify` to .swiftinterface files
so they can be read by the draft implementation in current
compilers.  Here are some of the issues:

* We _cannot_ support `read`/`modify` in Swift sources without
  the user specifying a flag. That's because the idiom below occurs
  in real code, and would be broken by such support.  So when
  we enable the `CoroutineAccessors` flag by default, we _must_
  not support `read`/`modify` as accessor notations in source.

```
struct XYZ {
  // `read` method that takes a closure
  func read(_ closure: () -> ()) { ... }

  // getter that uses the above closure
  var foo: Type {
    read { ... closure ... }
  }
}
```

* .swiftinterface files don't have the above problem.
  Accessor bodies aren't stored at all by default, and
  when inlineable, we always write explicit `get`.
  So we can continue to accept `read`/`modify` notation
  in interface files.

So our strategy here is:

* We'll accept both `read`/`modify` and `yielding borrow`/`yielding mutate`
  in interface files for a lengthy transition period.

* We'll write `read`/`modify` to swiftinterface files for
  a little longer, then switch to `yielding borrow`/`yielding mutate`.

* We'll disable `read`/`modify` support in source files
  when we enable `CoroutineAccessors` by default.
  (We can't even diagnose, due to the above idiom.)

This means that early adopters will have to update their sources
to use the new terminology.  However, swiftinterface files
will be exchangeable between the new and old compilers for a little
while.
2026-01-21 07:01:46 -08:00
Michael Gottesman
39357074fb Merge pull request #86526 from gottesmm/pr-e2e8ef6e601b5787cdde9000bd3275202ee8bf49
[basic] Add llvm::reportFatal{Internal,Usage}Error that use a llvm::raw_ostream closure based API so normal C++ dumpers can be used ergonomically.
2026-01-14 18:29:05 -08:00
Michael Gottesman
945482dd9d [basic] Add llvm::reportFatal{Internal,Usage}Error that use a llvm::raw_ostream closure based API so normal C++ dumpers can be used ergonomically.
LLVM is switching to use these APIs instead of report_fatal_error. One
unfortunate characteristic of these APIs is that they take Twines and StringRefs
so if one wants to use a type that uses raw_ostream based print APIs, one has to
by hand create a SmallString, create an ostream to put the value into the
SmallString and then call the API. These helpers just perform that initial bit
of work of creating the SmallString and ostream and pass in the ostream to the
callback. After the callback returns, we pass the SmallString to
reportFatal{Internal,Usage}Error.

I also imported the llvm APIs into the swift namespace as well.
2026-01-13 09:13:32 -08:00
Michael Gottesman
6a130f28c1 [multimap] Expose reverse iterators for the internal vector storage. 2026-01-13 09:12:33 -08:00
Kavon Farvardin
adf14929f9 Merge pull request #86337 from kavon/noncopyable-opaque-read-ownership
introduce UnderscoreOwned feature
2026-01-07 18:58:54 -08:00
Henrik G. Olsson
1351798ff7 Merge pull request #86138 from hnrklssn/swiftify-swift-shims
[Swiftify] don't attach macro when module does not import stdlib
2026-01-06 22:57:37 -08:00
Kavon Farvardin
458b62c9ed introduce UnderscoreOwned feature
This experimental feature allows you to override the default behavior
of a 'get' returning a noncopyable type, so that it returns an owned
value rather than a borrow, when that getter is exposed in opaque
interfaces like protocol requirements or resilient types.

resolves rdar://157318147
2026-01-06 16:39:54 -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
Pavel Yaskevich
a5b1b5b37e Merge pull request #86128 from xedin/remove-GroupActorErrors
[Concurrency] Remove experimental feature `GroupActorErrors`
2025-12-22 07:51:39 -08:00
Slava Pestov
9157d984e9 Sema: Convert solver arena usage into an always-on statistic 2025-12-19 17:26:19 -05:00
Henrik G. Olsson
75a110cdc6 [Swiftify] don't attach macro when module does not import stdlib
This prevents stuff like memcmp from SwiftShims from being imported with
@_SwiftifyImport, which would then result in name lookup errors as it
does not import the Swift standard library module. This makes the
previous approach to disable safe interop when compiling with
-parse-stdlib redundant.

irdar://165856959
2025-12-18 21:14:58 -08:00
Pavel Yaskevich
1f229d816b [Concurrency] Remove experimental feature GroupActorErrors
We have decided not to pursue this direction.
2025-12-18 11:01:53 -08:00
Slava Pestov
ea587322dc Sema: New StrictAccessControl upcoming feature
Some access control holes were unconditionally downgraded to warnings, and
others were conditional on Swift 6 language mode. Let's hang them off an
upcoming feature instead.
2025-12-15 18:02:52 -05:00
Artem Chikin
0a4d352844 De-register temporary buffer 'SourceFile's created during availability attribute argument parsing
Otherwise these source file objects linger in the source manager but they refer to a fully-temporary 'ASTContext' which does not exist after parsing is complete, which means they cannot be used in any way and attempting to do so would lead to a crash.
2025-12-12 10:14:21 -08:00
Artem Chikin
8e97cb4d8d Implement support for unified warning group behavior queries per-diagnostic
Unified across module-wide configuration flags (`-Wwarning`, `-Werror`, etc.) and syntactic configuration attribute `@warn`.
2025-12-12 10:14:20 -08:00
Artem Chikin
e593fd97a0 Add parsing for a declaration attribute '@warn' for source-level warning group behavior control 2025-12-12 10:14:14 -08:00
Michael Gottesman
e186e5e5d0 Merge pull request #85972 from gottesmm/pr-9663abc1697da1382a8514e6877a6c3ce3f439b9
[concurrency] Hide Concurrency StackNesting builtins behind a feature flag
2025-12-11 21:16:37 -08:00
Arnold Schwaighofer
c1c05e1298 Merge pull request #85948 from aschwaighofer/embedded_enable_existential_support
[embedded] Enable support for existentials/boxed protocol types per default
2025-12-11 07:16:26 -08:00
Michael Gottesman
7b9281fcb8 [concurrency] Hide Concurrency StackNesting builtins behind a feature flag.
rdar://166244033
2025-12-10 16:02:18 -08:00
Arnold Schwaighofer
d019f37b68 [embedded] Enable support for existentials/boxed protocol types per default
And enable this feature in production.
2025-12-10 08:50:23 -08:00
Egor Zhdan
a6b30c4dd0 Merge pull request #85869 from egorzhdan/egorzhdan/remove-interop-compat-version
[cxx-interop] Remove compatibility versions
2025-12-09 15:45:00 +00:00
Hamish Knight
45683f6561 [Sema] Exclude private initialized vars from memberwise initializer
Exclude properties with initial values from the memberwise initializer
if they are less accessible than the most accessible property, up to
`internal`. Introduce a compatibility overload that continues to
include the same properties as before until the next language mode.

This is gated behind the `ExcludePrivateFromMemberwiseInit` feature.

rdar://122416579
2025-12-08 23:22:35 +00:00
Egor Zhdan
69be33d3ba [cxx-interop] Remove compatibility versions
This removes the C++ interop compat version mechanism. It was added in mid-2023 and was never used. It complicates the testing story, and makes it harder to reason about the compiler's behavior. It also isn't compatible with explicit module builds.

The flag `-cxx-interoperability-mode` is preserved, so projects that use the flag will continue to build normally.

rdar://165919353
2025-12-05 18:01:09 +00:00
Egor Zhdan
b0ec567c0e [cxx-interop] Remove dead code: isCxxInteropCompatVersionAtLeast
rdar://165919353
2025-12-05 17:48:02 +00:00
Anthony Latsis
153dd02cd8 Merge pull request #85833 from swiftlang/jepa-main
[NFC] "SwiftVersion" → "LanguageMode" in `DiagnosticEngine::warnUntilSwiftVersion`, etc.
2025-12-05 09:34:30 +00:00