Commit Graph

48354 Commits

Author SHA1 Message Date
Mike Ash 3dce226714 Merge pull request #87052 from mikeash/checked-objc-async-completion-name-collision-fix
[Concurrency] Emit a distinct mangling for checked ObjC async completion handlers.
2026-02-11 10:40:53 -05:00
Erik Eckstein acd5227639 SIL: add isDestructive and mayBeDestructive to UncheckedTakeEnumDataAddrInst 2026-02-11 06:43:46 +01:00
Artem Chikin f53ccd656d Merge pull request #86934 from artemcm/LiteralExpressionEnumRawValues
[Literal Expressions] Add support for literal expressions in enum raw values
2026-02-10 22:28:59 +00:00
Saleem Abdulrasool 10efdbd240 Merge pull request #86797 from sundresh/sundresh/windows_trace_events_stats
Ensure trace CSVs include entry and exit for all events on Windows, with microsecond-level timing
2026-02-10 14:25:12 -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 2627c91576 Basic: Replace Version::getValidEffectiveVersions with LanguageMode::allSupportedModes 2026-02-10 16:07:00 +00:00
Anthony Latsis 3dce828a4d Remove now unused methods that expect an integral language mode 2026-02-10 16:06:59 +00:00
Anthony Latsis abf1ca69b4 Basic: Switch upcoming features to LanguageMode 2026-02-10 16:06:58 +00:00
Anthony Latsis 85db41932d Switch ASTContext::isLanguageModeAtLeast to LanguageMode 2026-02-10 16:06:58 +00:00
Anthony Latsis 31cafb0a27 Switch DiagnosticEngine::warnUntilLanguageMode and co. to LanguageMode 2026-02-10 16:06:56 +00:00
Anthony Latsis 1900bb70d7 Basic: Introduce a safe, structured representation for language modes 2026-02-10 16:06:51 +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
Artem Chikin 1e5ba5fca8 [Literal Expressions] Add support for literal expressions in enum raw values
Modify relevant portions of the type-checker and parser to allow, when the 'LiteralExpressions' experimental feature is enabled, for arbitrary integer-typed expressions in enum raw value specifiers. These expressions will be type-checked and constant-folded into an integer literal expression, keeping the current interface of 'EnumElementDecl' consistent for clients.

Previously, 'EnumRawValuesRequest' had two different "modes" which were discerned based on typechecking stage (structural | interface), where the former had the request compute all raw values, both user-specified literal expressions and computing increment-derived values as well; the latter would also type-check the user-specified expressions and compute their types.
- With the need to have enum case raw values support arbitrary integer expressions, the request ('EnumRawValuesRequest') has been refactored and simplified to *always* both compute all case raw values and perform type-checking of user-specified raw value expressions. This is done in order to allow the AST-based constant-folding infrastructure ('ConstantFoldExpression' request) to run on the expressions. Constant folding is invoked during the evaluation of 'EnumRawValuesRequest' on all user-specified raw value expressions, in order to be able to compute subsequent increment values and ensure the expressions are foldable. If they are not, i.e. if constant folding fails, a relevant diagnostic will be emitted.
- 'EnumElementDecl' continues to store the raw value expression, which is no longer a 'LiteralExpr' but rather an 'Expr'; however, the getter ('getRawValueExpr') continues to return a 'LiteralExpr' by invoking the constant-folding request on the stored value, which is guaranteed to return a cached result from a prior invocation in 'EnumRawValuesRequest', assuming it succeeded.
- Furthermore, the 'structural' request kind was previously not cached, whereas now because the request must always do the complete type-checking work, it is always cached.

Resolves rdar://168005520
2026-02-10 09:43:07 +00:00
Hamish Knight f0e9a61297 Merge pull request #87078 from hamishknight/fixed-dir
Replace `vfs::getRealFileSystem` -> `vfs::createPhysicalFileSystem`
2026-02-10 00:28:08 +00:00
John Hui 03530d6211 Merge pull request #87065 from j-hui/load-storage-members
[MemberLoading] Split storage and non-storage member loading
2026-02-09 16:10:26 -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
Artem Chikin 2f0ba5820c Merge pull request #86500 from artemcm/LiteralExpressions
[Literal Expressions] Add support for simple constant-folded literal expressions
2026-02-09 16:20:09 +00:00
Artem Chikin 0bbd35242c [Literal Expressions] Add support for simple constant-folded literal expressions
This change adds an experimental feature 'LiteralExpressions` which allows for use of simple binary expressions of integer type composed of literal value operands.

For now, such literal expressions are only supported in initializers of '@section` values.
2026-02-09 11:35:45 +00:00
Hamish Knight eb45f2396d Replace vfs::getRealFileSystem -> vfs::createPhysicalFileSystem
Calling `setCurrentWorkingDirectory` on `getRealFileSystem` sets the
working directory for the process itself. This is unsafe for clients
such as SourceKit which can process multiple concurrent requests,
and may be used as an in-process library in e.g sourcekit-lsp. Switch
to `createPhysicalFileSystem` instead, where setting the working
directory is done locally on the FileSystem itself.
2026-02-09 09:46:34 +00:00
John Hui 5bd319a59a [MemberLoading] Split storage and non-storage member loading
Doing so allows further granularity when lazily loading members.
2026-02-07 17:17:34 -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
Doug Gregor 8fb9727dfe Merge pull request #87040 from DougGregor/target-arch-variant
Accept and ignore -target-arch-variant
2026-02-06 16:35:31 -08:00
Hamish Knight 681c4d22c6 Merge pull request #87031 from hamishknight/revert-hack
Revert "[CS] Add `for` loop compatibility hack for `makeIterator`/`next` ranking"
2026-02-06 22:54:16 +00:00
Mike Ash 2abf087e71 [Concurrency] Emit a distinct mangling for checked ObjC async completion handlers.
This avoids coalescing checked and unchecked handlers with the same types, which results in runtime crashes as they are not compatible.

We have a separate mangling for predefined handlers, TZ, which is unused. Repurpose this for checked handlers. Unchecked handlers keep their existing mangling with Tz.

rdar://152263818
2026-02-06 17:45:43 -05:00
Aidan Hall 88b2c1c056 Merge pull request #86846 from aidan-hall/disable-lifetime-indices
LifetimeDependence: Disable parameter indices in Swift lifetime dependence annotations
2026-02-06 22:34:52 +00:00
Hamish Knight 2ddadb6a0c Merge pull request #87028 from hamishknight/privy
[Sema] SE-0502: Enable `ExcludePrivateFromMemberwiseInit` by default
2026-02-06 21:40:03 +00:00
Kavon Farvardin 6dda8b98d9 Reparenting: require statement of inheritance
We were walking the extensions of protocols in
requirement lowering and in getInheritedProtocols
to also count the @reparented entries in all
extensions. I had already seen some request
evaluator cycles triggered by this with objc
protocols, and it seems unnessecary as it's
actually a benefit to force people to write the
inheritance on the protocol itself.
2026-02-06 13:23:22 -08:00
Doug Gregor 421ec521c8 Accept and ignore -target-arch-variant 2026-02-06 10:35:44 -08:00
Alastair Houghton e38c0652b6 Merge pull request #84906 from al45tair/eng/PR-101623384
[Backtracing] Add initial support for Windows.
2026-02-06 14:53:16 +00:00
Hamish Knight 0036130988 Revert "[CS] Add for loop compatibility hack for makeIterator/next ranking"
This reverts commit 7b729933f6.
2026-02-06 12:47:25 +00:00
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
Kavon Farvardin ae77ba81e3 Merge pull request #87013 from kavon/revert-84789
Back out #84789 after additional testing
2026-02-06 02:58:00 -08:00
Aidan Hall 63da6499eb LifetimeDependence: Disable indices in Swift lifetime dependencies
Lifetime indices are never necessary in Swift, they unnecessarily expose
implementation details, and they make lifetime annotations more error-prone,
since they may need to be updated if a function's parameter list changes.

The Swift Syntax parser also cannot handle lifetime annotations where the target
is an index. The main reason the C++ parser supports them is because it is also
used for SIL.
2026-02-06 10:27:01 +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
Alastair Houghton ceaba82d6d [Backtracing] Updates after review.
Tweaked the comment in `Runtime/Config.h`.

Fixed a couple of incorrect ARM64 instruction mnemonics.  This still needs
testing on ARM64 Windows.

Fixed an out-of-date comment in `swift-backtrace`.

Use a macro in `Backtrace.cpp` to guarantee we don't overrun the buffer,
and in the process simplify the code slightly.

rdar://101623384
2026-02-06 08:53:16 +00:00
Hiroshi Yamauchi 36be4d294e Remove Clang CASFS (#86973) 2026-02-05 19:32:08 -08:00
Alexis Laferrière 395f1227d5 Merge pull request #86964 from xymus/deser-diag-member
Serialization: Raise a proper error on type members broken by invalid modularization
2026-02-05 16:33:27 -08:00
Slava Pestov 1b717b37d3 Merge pull request #86993 from slavapestov/move-code-around-in-solver
Sema: Move some code around
2026-02-05 16:16:20 -05:00
Kavon Farvardin d5f9a1eeeb Revert "Merge pull request #84789 from nickolas-pohilets/mpokhylets/fix-82618"
This reverts commit b633bd37ac, reversing
changes made to b27bb64b03.
2026-02-05 11:34:59 -08: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
Alexis Laferrière 0ac40aada4 Serialization: Error on type members broken by invalid modularization
Extend support for proper errors on broken modularization to type
members, previously only top-level declarations were reported as error.
This change raises errors with relevant context if a type member is
referenced from a swiftmodule file but at reading the member is not
found or changed shape.

It doesn't report moves between modules like we do for top-level
declarations. This is less likely to happen at the member level as the
check is already applied at the top-level for the same reference. We may
still see such issues when using `SWIFT_NAME` to assign a top-level
declaration to a type from a different module.
2026-02-05 09:56:31 -08:00
Aidan Hall a366c4765a [AST] Print function type LifetimeDependenceInfo using parameter labels
We fall back to indices when labels are not available, but labels are
preferable, because they readable, stable, and preferred by the lifetime
dependencies proposal.
2026-02-05 14:50:39 +00:00
Aidan Hall 7b9db38984 LifetimeDependence: Support function types
To a function type's lifetimes, a base version of the type is first created with
no lifetime dependence info. This is then passed to the dependence checker, and
the resulting dependencies are added to it.

It would be possible to do this analysis by passing just the parameter list and
result type (which are available before the type is created), but this approach
lets us avoid dealing with a header inclusion cycle between Types.h, ExtInfo.h,
and LifetimeDependence.h, since it does not require AnyFunctionType::Param to be
defined in LifetimeDependence.h.
2026-02-05 14:50:27 +00:00
Aidan Hall e401b1a720 [AST] Support multiple of the same attribute per type 2026-02-05 14:50:21 +00:00
Aidan Hall 805d8e9e26 Add language feature ClosureLifetimes 2026-02-05 14:50:14 +00:00
Aidan Hall b2c79211af Types: + AnyFunctionType::hasExplicitLifetimeDependencies 2026-02-05 14:50:14 +00:00
Aidan Hall fbb2da1526 Serialization: Add LifetimeDependenceInfo.isFromAnnotation to module format
The isFromAnnotation flag is set if and only if the lifetime originates from a
@lifetime or @_lifetime annotation in the source program.

isFromAnnotation==false means that the lifetime dependence checker would infer
the same lifetime if the Swift type or decl was printed without an annotation
for that dependency. More specifically, it means that the depenence was inferred
by the lifetime dependence checker.

Some dependencies on imported C/C++ decls are "inferred", but they either
correspond to explicit lifetime information in the source (smart pointers,
lifetimebound attribute) or are likely to differ from what the dependence
checker would infer. As such, we set the flag to true for all of them.
2026-02-05 14:50:04 +00:00
Slava Pestov 9036602aa1 Sema: Split off BindingProducer.h/.cpp 2026-02-05 09:19:01 -05:00
Slava Pestov 78e9329184 Sema: Move OpenUnboundGenericType to CSGen.cpp 2026-02-05 09:19:01 -05:00
Slava Pestov b1e1cba094 Sema: Remove unused OverloadSetCounter 2026-02-05 09:19:01 -05:00