Commit Graph

1980 Commits

Author SHA1 Message Date
susmonteiro
e2752096b6 [cxx-interop] Add CxxBorrowingSequence to the C++ stdlib overlay 2026-02-13 08:37:29 +00:00
elsa
af7069a10e Merge pull request #86811 from elsakeirouz/for-in-borrowing-support-no-stdlib-changes
ForEach support for Borrowing sequence

For testing purposes, this commit includes _BorrowingSequence and _BorrowingIterator protocols, with conformance for Span and InlineArray.
2026-02-12 10:08:24 +00:00
Hamish Knight
64d4e85b13 Merge pull request #87139 from hamishknight/return-to-sender
[CS] A couple of Sendable dependence fixes
2026-02-11 21:06:37 +00:00
Steven Wu
ce64a73316 Merge pull request #87098 from cachemeifyoucan/eng/PR-169886913
[SDKInfo] Fix SDKInfo loading to use correct VFS
2026-02-11 09:58:40 -08:00
Elsa Keirouz
2a0bc57763 [AST] desugar ForEachStmt for BorrowingSequence protocol 2026-02-11 16:02:25 +00:00
Hamish Knight
131073553d [AST] Fold away sendable dependence for replacingTypeVariablesAndPlaceholders
Make sure we eliminate the type variables present in the sendable
dependent type if present.
2026-02-11 12:08:32 +00:00
Anthony Latsis
85db41932d Switch ASTContext::isLanguageModeAtLeast to LanguageMode 2026-02-10 16:06:58 +00:00
Steven Wu
17d969924c [SDKInfo] Fix SDKInfo loading to use correct VFS
Partially revert https://github.com/swiftlang/swift/pull/86309. Keep the
SDKInfo parsing in the ASTContext separately from the search path
configuration. This allows the availablity checking to load SDKSettings
from the correct VFS.

rdar://169886913
2026-02-09 15:03:53 -08:00
Hamish Knight
2bcd8c791e [AST] Introduce Sendable-dependent functions
These will allow the constraint system to represent function types 
that have sendability that depends on the sendability of an
unresolved type.
2026-01-27 11:06:54 +00:00
Joe Groff
373211a902 SILGen: Lowering for Builtin.makeBorrow 2026-01-23 08:02:08 -08:00
Joe Groff
bc166d5a8c Add a Builtin.Borrow type.
This will represent the layout of a borrow of a value.
2026-01-23 07:46:50 -08:00
Steven Wu
9d76a62a33 Merge pull request #86501 from cachemeifyoucan/eng/PR-167784812
[ScanDependency] Fix canImport when versioned checks all eval to false
2026-01-21 09:59:21 -08:00
Michael Gottesman
f10ca1c949 [sil] Add convenience APIs to SILBoxType for generics safe field access
Before this patch it was easy to try to work with the types in a SILBoxType by
accessing the layout of the SILBoxType... especially if one was working with
mutability since there wasn't any comment/APIs on SILBoxType that pointed one at
the appropriate API on SILType.

To make this easier to use and self document, I added some new helper APIs onto
SILBoxType that:

1. Let one grab the fields without touching the layout. The layout is an
internal detail of SILBoxType that shouldn't be touched unless it is necessary.

2. Get a specific properly specialized SILType of a SILType for a given
SILFunction.

3. Access the number of SILFIelds and also whether or not a specific SILField is
mutable.

4. Yields a transform range that transform the SILFields in the SILBoxType into
a range of properly specialized SILTypes.

This should prevent these sorts of mistakes from happening in the future.
2026-01-16 08:22:21 -08:00
Michael Gottesman
307892451f [ast] Add a new helper SILBoxType::withMutable to take in a SILBoxType and produce a new BoxType with mutated mutability of its fields.
This is properly prepared for multiple field boxes since we take in an
initializer_list of fields/mutability changes.

Given that I made this change to SILBoxType, I aligned the same API on SILLayout
to also take an initializer_list of fields/mutability changes instead of just
assuming a single field layout.
2026-01-16 08:22:21 -08:00
Steven Wu
c5189de182 [ScanDependency] Fix canImport when versioned checks all eval to false
Fix a corner case when following conditions are met in a single module:
* Module A is imported in the current module
* There exists a versioned `canImport` check for a module A
* All `canImport` check within the module evaluated to false

If all above conditions are met, swift-frontend will not received the
version number from scanner, and it will be confused if version is
either not available (thus a warning, and treat as true), or condition
is not met (eval to false).

Now make sure if when scanner tries to resolve `canImport`, it will
record all instances that a module can be imported, or a version of the
module is found.

rdar://167784812
2026-01-12 15:57:52 -08:00
Ian Anderson
48ab4b0595 [Frontend][Darwin] Use the system prefix from SDK when constructing the default search paths
Some Darwin platforms like DriverKit use a system prefix on all of their search paths. Even though DriverKit isn't supported, add support to get the system prefix from SDKSettings when constructing the default search paths.

This requires the DarwinSDKInfo to be gotten earlier in CompilerInvocation, pass that down to ASTContext through CompilerInstance.

-platform-availability-inheritance-map-path is no longer needed to support visionOS in tests, remove that and its supporting code that gets an alternative DarwinSDKInfo.

rdar://166277280
2026-01-09 12:41:32 -08:00
Artem Chikin
828813c7e4 Merge pull request #85036 from artemcm/AddSupportForWarnAttr
Add support for a declaration attribute `@warn` for source-level warning group behavior control
2025-12-14 19:14:36 -08:00
Slava Pestov
54521bd21b AST: Canonicalize opaque archetype substitution maps in the solver arena
Preserving sugar if we have type variables uses way too much memory.

Canonicalize these substitution maps for now, as a (temporary?) workaround.

In the future, if we decide preserving sugar is more important than a
few dozen Mb of memory usage, we can also bump the arena memory limit,
instead.

Fixes rdar://166237860.
Fixes rdar://165863647.
2025-12-12 18:11:04 -05: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
Hamish Knight
302e803b2f [AST] Store original lazy VarDecl for backing storage
Store the original VarDecl in the same map we use for tracking the
original wrapper var for property wrappers. This will allow us to
use the same logic to determine the original var for both.
2025-12-08 23:22:35 +00:00
Anthony Latsis
88220a33c3 [NFC] "SwiftVersion" → "LanguageMode" in DiagnosticEngine::warnUntilSwiftVersion, etc. 2025-12-04 15:11:07 +00:00
Slava Pestov
27097430cc Serialization: Lazily deserialize OpaqueTypeDecl's underlying substitutions
We need to serialize the underlying type substitution map for an
inlinable function. However, there is no reason to deserialize it
eagerly, since doing so can lead to cycles. It is better for
correctness and performance to only deserialize it when needed.

Technically this fixes a regression from #84299, but the actual
problem was there all along, it was just exposed by my change
on a specific project.

Fixes rdar://163301203.
2025-11-20 18:13:50 -05:00
Slava Pestov
819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Anthony Latsis
8992ea82a2 Merge pull request #85433 from swiftlang/jepa-main4
AST: Rename `GenericContext::isGeneric` to `hasGenericParamList`
2025-11-11 21:12:34 +00:00
Anthony Latsis
bda6edb85c AST: Rename GenericContext::isGeneric to hasGenericParamList
`isGeneric` is a misleading name because this method checks for the
existence of a `GenericParamList`, which is not implied by genericity.
2025-11-11 15:55:16 +00:00
Hamish Knight
33e6c0fb6c [AST] Also cache protocol kind in getBuiltinInitDecl
Make sure we don't return the wrong witness if you query with 2
different builtin protocol kinds.
2025-11-10 15:57:33 +00:00
Hamish Knight
92e5e7b5b7 [AST] Remove asserts from getBuiltinInitDecl
Allow querying for types that may not conform. Failures here should
be asserted downstream (e.g in `setBuiltinInitializer`).
2025-11-10 15:57:33 +00:00
Joe Groff
e002d96ac9 Merge pull request #85169 from jckarter/builtin-generic-base-class
Add a BuiltinGenericType base class.
2025-10-31 12:45:58 -07:00
Becca Royal-Gordon
393965090e Merge pull request #34556 from beccadax/mod-squad-2
[SE-0491] Implement lookup and diagnostics for module selectors (MyMod::someName)
2025-10-28 16:00:26 -07:00
Joe Groff
cf5f7c8637 Add a BuiltinGenericType base class.
Builtin.FixedArray was introduced as the first generic builtin type, with
special case handling in all the various recursive visitors. Introduce
a base class, and move the handling to that base class, so it is easier
to introduce other generic builtins in the future.
2025-10-28 12:48:18 -07:00
Becca Royal-Gordon
64d8b70942 Make DeclNameRef able to store a module selector
In this commit, this change affects certain diagnostics but doesn’t actually alter name lookup behavior yet.
2025-10-24 16:23:33 -07:00
Adrian Prantl
c91211a5d2 Serialize explicit module dependencies in swift module files
For clients, such as the debugger, who do not have access the full
output of the dependency scanner, it is a huger performance and
correctness improvement if each explicitly built Swift module not just
serialized all its Clang .pcm dependencies (via the serialized Clang
compiler invocation) but also its direct Swift module dependencies.

This patch changes the Swift module format to store the absolute path
or cas cache key for each dependency in the INPUT block, and makes
sure the deserialization makes these available to the ESML.

rdar://150969755
2025-10-21 09:08:58 -07:00
Allan Shortlidge
3151bcb1d8 Merge pull request #84943 from tshortli/silgen-swift-runtime-availability
stdlib/SILGen: Emit SIL for Swift runtime availability queries
2025-10-16 15:08:09 -07:00
Hamish Knight
73710e3eef [AST] Introduce Decl::addAttribute
Introduce a convenience entrypoint that also calls `attachToDecl` on
the attribute, and migrate all existing uses of `getAttrs().add` onto
it.
2025-10-16 11:21:54 +01:00
Allan Shortlidge
085f8ecca9 stdlib/SILGen: Emit SIL for Swift runtime availability queries.
When emitting SIL for `if #available(Swift ..., *)` queries, call the new
`_isSwiftRuntimeVersionAtLeast()` function in the stdlib to check the
condition. To support back deployment, the implementation of
`_isSwiftRuntimeVersionAtLeast()` is `@_alwaysEmitIntoClient` and performs its
comparison against the result of `_SwiftStdlibVersion.current`, which is
pre-existing ABI that the stdlib exposes for querying the Swift runtime
version.

Resolves rdar://162726037.
2025-10-15 22:42:53 -07:00
Hamish Knight
a83ea3c8bb Merge pull request #84745 from hamishknight/fishmonger
[Evaluator] Enforce consistent results for cyclic requests
2025-10-09 17:08:04 +01:00
Hamish Knight
48ac5126d9 [AST] Fold away nested ErrorTypes
Remove the now-unnecessary hack where we could build recursive
ErrorTypes.
2025-10-08 21:16:02 +01:00
Hamish Knight
e7c7239587 [Sema] Insert ErrorType same-type constraints for placeholder signatures
This helps avoid producing more downstream errors. This changes
`GenericSignature::forInvalid` to produce the same signature as e.g
`<T where T == Undefined>`. This subsumes the need to introduce
conformance requirements for invertible protocols.
2025-10-08 21:16:02 +01:00
Hamish Knight
f7e459a9b5 [AST] Factor out GenericSignature::forInvalid
Factor out the common logic from `getPlaceholderGenericSignature`.
2025-10-08 21:16:02 +01:00
Slava Pestov
8cf491f825 AST: Allow non-canonical opaque archetypes 2025-10-08 15:15:50 -04:00
Slava Pestov
0d90b62491 AST: Clean up in preparation for non-canonical archetypes 2025-10-08 15:15:43 -04:00
Becca Royal-Gordon
60b3b088d5 Merge pull request #84358 from beccadax/common-concurrency 2025-10-07 12:21:50 -07:00
Hamish Knight
954b08cae5 [AST] Remove UnresolvedType
We have now removed all uses of this type.
2025-10-03 09:50:42 +01:00
Hamish Knight
21141f466c [AST] Add queries for 'bare' error types
Add `hasBareError` and `isBareErrorType` to check whether a type is
an ErrorType without an underlying original type (i.e prints as `_`).
2025-10-03 09:50:42 +01:00
Becca Royal-Gordon
3abbfaa9cb Introduce separately-imported stdlib overlays
The `_Concurrency` and `_StringProcessing` modules are implementation details of the standard library; to developers, their contents should behave as though they are declared directly within module `Swift`. This is the exact same behavior we expect of cross-import overlays, so treat these modules as though they are cross-import overlays with no bystanding module.

Because these modules don’t re-export the standard library, it’s also necessary to treat `Swift` as a separately imported overlay of itself; do so and make that actually work.
2025-10-02 12:05:12 -07:00
swift-ci
7b3444a39f Merge remote-tracking branch 'origin/main' into rebranch 2025-09-29 10:58:38 -07:00
Hamish Knight
1c4132f005 [AST] Remove the use of UnresolvedType in replacingTypeVariablesAndPlaceholders
Now that ErrorType prints as `_`, we can use that instead of UnresolvedType
here since the original type is only really used for type printing and
debugging.
2025-09-28 15:13:55 +01:00
swift-ci
9e3d4161b5 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-18 05:03:55 -07:00
Hamish Knight
5e1acf5d32 [AST] Preserve HasPlaceholder recursive property for GenericFunctionType 2025-09-17 20:41:20 +01:00
Anthony Latsis
e1450e011e Manually merge remote-tracking branch 'origin/main' into rebranch
Conflicts:
*	utils/build_swift/build_swift/defaults.py
2025-09-04 14:07:50 +01:00