Commit Graph

22502 Commits

Author SHA1 Message Date
Andrew Trick
c494124d11 Allow Builtin.Take -> ~Escapable 2025-10-05 20:17:47 -07:00
Hamish Knight
9a9a6a3b98 Merge pull request #84694 from hamishknight/tuple-trouble
[Sema] Reject tuple extensions early when feature is disabled
2025-10-05 20:53:37 +01:00
Hamish Knight
f643f3d990 [Evaluator] Add "through" to "declared here" request cycle notes
Make it a bit clearer that these are steps in the request cycle.
2025-10-05 20:48:08 +01:00
Hamish Knight
13023de4c4 [Evaluator] Avoid emitting duplicate "through reference here" notes
Filter out any duplicate notes to help cut down on the noise for
request cycle diagnostics. Some of the note locations here still aren't
great, but this at least stops us from repeating them for each
intermediate request.
2025-10-05 20:48:08 +01:00
Hamish Knight
382a52ed2f [AST] NFC: Add Diagnostic::getLocOrDeclLoc 2025-10-05 20:48:08 +01:00
Slava Pestov
811a201bc1 Merge pull request #84675 from slavapestov/rqm-protocol-failure-bookkeeping
RequirementMachine: New way of propagating failure when building rewrite system for protocol
2025-10-05 14:10:00 -04:00
Hamish Knight
8ec8902e56 [Sema] Reject tuple extensions early when feature is disabled
Tuple extensions are still an experimental feature, but we have a
number of crashers in the repo for them because we still use their
type-checker machinery even when disabled. Change the logic here such
that we reject them early in extension binding when the feature is
disabled. This will ensure we address the crashers before productizing.
2025-10-05 11:22:54 +01:00
Hamish Knight
7465928b45 [AST] Canonicalize original type for ErrorType
Make sure we canonicalize the original type for an ErrorType to ensure
that diagnostic logic can coalesce ErrorTypes that have the same
canonical type.
2025-10-05 11:19:59 +01:00
Slava Pestov
244d2afea3 RequirementMachine: New way of propagating failure when building rewrite system for protocol
If we failed to construct a rewrite system for a protocol, either because
the Knuth-Bendix algorithm failed or because of a request cycle while
resolving requirements, we would end up in a situation where the resulting
rewrite system didn't include all conformance requirements and associated
types, so name lookup would find declarations whose interface types are
not valid type parameters.

Fix this by propagating failure better and just doing nothing in
getReducedTypeParameter().

Fixes rdar://147277543.
2025-10-04 09:17:46 -04:00
Doug Gregor
9fa9ea761b Merge pull request #84676 from DougGregor/c-implementation-import-lookup
[SE-0495] Make sure we can find imported C functions for @c @implementation
2025-10-03 21:42:00 -07:00
Doug Gregor
67c7fbc87b [SE-0495] Make sure we can find imported C functions for @c @implementation
@c @implementation relies on matching the original C declaration. The
lookup for the original C declaration was doing the wrong kind of
lookup, meaning that it could only find the C declaration if it came
through a bridging header, and not through a normal module import.
Using unqualified lookup here finds the name appropriately.

Clarify the diagnostics here as well to not talk about umbrella and
bridging headers.

Fixes rdar://161909754.
2025-10-03 12:03:12 -07:00
Slava Pestov
1731b09a88 AST: Don't return null Type() from getTypeWitness() 2025-10-03 14:24:10 -04:00
Meghana Gupta
ea0e0173b4 Merge pull request #84595 from meg-gupta/moreborrowaccessors
Extend borrow accessor support
2025-10-03 11:14:49 -07:00
John Hui
be453cfc49 [cxx-interop] Make imported enum members inherit the access of their parent (#84522)
This patch relaxes the access check for members of imported inherited
nested enums. Without it, those members become impossible to inherit,
which largely defeats the purpose of importing them in the first place.

rdar://160803362
2025-10-03 10:20:25 -07:00
Egor Zhdan
e0df8cd100 [cxx-interop] Avoid spurious references to _OBJC_CLASS symbols for C++ foreign reference types
This removes erroneous references to `_OBJC_CLASS_$__xyz` symbols that Swift was emitting for certain usages of C/C++ foreign reference types. This was discovered when trying to iterate over a Swift array of foreign reference types using a Swift for-in loop.

`Builtin.canBeClass` was returning true for foreign reference types, which led to the optimizer specializing the generic `canBeClass<T>` function to unconditionally return true for foreign reference types. This meant that `_isClassOrObjCExistential` for a foreign reference type evaluated to true, which made the Swift stdlib take the code path that was intended for Objective-C classes in `ArrayBuffer.getElement`, which assumed that the `Element` type conforms to `AnyObject`. Foreign reference types do not actually conform to `AnyObject`.

rdar://161814644
2025-10-03 15:01:34 +01: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
5171b84dba [CS] Replace UnresolvedType with ErrorType in simplifyType/resolveType
This means we now either produce a bare ErrorType, or an ErrorType
with a generic parameter original type for a generic parameter hole.
We ought to further consolidate this logic by sinking the generic
parameter original type replacement into `simplifyType` itself, but
I'm leaving that for a future patch since it affects completion
results and I want to try keep this close to NFC.
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
Mishal Shah
03a599c5be Merge pull request #84606 from swiftlang/rebranch
Merge clang 21.x rebranch into main
2025-10-02 20:17:05 -07: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
Meghana Gupta
fa7281d66e Introduce a new attribute @_unsafeSelfDependentResult
It can be used in borrow/mutate accessors to unsafely specify that the
result is dependent on the self access.
2025-10-02 07:42:07 -07:00
Arnold Schwaighofer
7853ba0a7f Merge pull request #84178 from aschwaighofer/inline_always
Add experimental feature `@inline(always)`
2025-10-01 07:23:24 -07:00
Doug Gregor
c4527dc47d Merge pull request #84580 from DougGregor/static-build-configure 2025-09-30 20:47:04 -07:00
Arnold Schwaighofer
3447bd1b31 Change implementation to infer @inlinable semantics from @inline(always) on public declarations 2025-09-30 08:36:32 -07:00
Arnold Schwaighofer
25a071efc8 Add experimental feature @inline(always)
The intent for `@inline(always)` is to act as an optimization control.
The user can rely on inlining to happen or the compiler will emit an error
message.

Because function values can be dynamic (closures, protocol/class lookup)
this guarantee can only be upheld for direct function references.

In cases where the optimizer can resolve dynamic function values the
attribute shall be respected.

rdar://148608854
2025-09-30 08:36:26 -07:00
Doug Gregor
2a46916536 Reseat CompilerBuildConfiguration on top of StaticBuildConfiguration
Now that we have a per-ASTContext StaticBuildConfiguration, reimplement
(almost) everything in CompilerBuildConfiguration to sit on top of it.
Only canImport requires the full ASTContext, so that gets its own
implementation, as does one other operation that can produce an error.
Aside from more code sharing, this provides additional validation that
the StaticBuildConfiguration we build is complete and accurate.
2025-09-29 18:42:15 -07:00
Doug Gregor
3082b04b75 [Macros] Feed the static build configuration into macro expansions
Thread the static build configuration (formed from language options) in
to the macro plugin handler, which will serialize it for use in the
macro implementation. test this with a simple macro that checks
whether a particular custom configuration (set via `-D`) is enabled or
not.

This required some re-layering, sinking the logic for building a
StaticBuildConfiguration from language options down into a new
swiftBasicSwift library, which sits on top of the C++ swiftBasic and
provides Swift functionality for it. That can be used by the C++
swiftAST to cache the StaticBuildConfiguration on the ASTContext,
making it available for other parts of ASTGen.
2025-09-29 18:42:15 -07:00
Doug Gregor
ae8f9d8234 Add -print-static-build-config to print a static build conformance
Introduce the ability to form a `StaticBuildConfiguration` from
language options. Add a frontend option `-print-static-build-config`
to then print that static build configuration as JSON in a manner that
can be decoded into a `StaticBuildConfiguration`.

Most of the change here is in sinking the bridged ASTContext queries
of language options into a new BridgedLangOptions. The printing of the
static build configuration only has a LangOptions (not an ASTContext),
so this refactoring is required for printing.
2025-09-29 18:42:14 -07:00
swift-ci
7b3444a39f Merge remote-tracking branch 'origin/main' into rebranch 2025-09-29 10:58:38 -07:00
Hamish Knight
0c58138a42 [Sema] Avoid using UnresolvedType in PatternTypeRequest
Return PlaceholderType instead of UnresolvedType, meaning we now
treat the following cases the same:

```
let x1 = foo
let x2: _ = foo
```
2025-09-28 15:13:55 +01: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
551a5e459d Merge remote-tracking branch 'origin/main' into rebranch 2025-09-26 16:16:15 -07:00
Alexis Laferrière
4c7a313de7 Merge pull request #84488 from xymus/c-impl-in-swiftinterfaces
ModuleInterface: Don't print `@c @implementation` functions
2025-09-26 16:09:34 -07:00
swift-ci
6b28979fb4 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-25 16:24:58 -07:00
Allan Shortlidge
2467b931a7 ConstraintSystem: Move key path type utilities to AST. 2025-09-25 07:13:17 -07:00
swift-ci
7eb35535da Merge remote-tracking branch 'origin/main' into rebranch 2025-09-24 08:34:30 -07:00
Hamish Knight
44efcb3a10 Merge pull request #84460 from hamishknight/open-and-shut
[CS] Fix typealias handling in InferableTypeOpener
2025-09-24 16:25:01 +01:00
Alexis Laferrière
0eaab86219 ModuleInterface: Don't print @c @implementation functions
We don't need to print the `@c @implementation` functions in
swiftinterfaces as clients need only to see the original declaration in
the C header. Don't print `@objc @implementation` functions either, but
still print simple `@c` and `@objc` functions.
2025-09-23 16:41:34 -07:00
swift-ci
e35756ef85 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 15:38:03 -07:00
Doug Gregor
0737723c5c Merge pull request #84465 from DougGregor/has-feature-library-evolution
Add an optional language feature for Library Evolution
2025-09-23 15:18:48 -07:00
swift-ci
7b46c3a797 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 15:16:42 -07:00
Alexis Laferrière
e5a9b6463d Merge pull request #84381 from xymus/rename-cdecl-to-c
Parser: Rename the experimental attribute `@cdecl` to the shorter `@c`
2025-09-23 14:58:46 -07:00
swift-ci
65bba7d138 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 11:57:20 -07:00
Egor Zhdan
4ef848701f Merge pull request #84354 from egorzhdan/egorzhdan/revert-extern-c
Revert "[cxx-interop] Import decls in extern blocks within namespaces"
2025-09-23 19:46:12 +01:00
swift-ci
0632073367 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 08:23:10 -07:00
Allan Shortlidge
d505527ff2 Merge pull request #84454 from tshortli/deprecated-custom-availability-domain-fix-its 2025-09-23 07:44:11 -07:00
Hamish Knight
b2854b28bf [CS] Fix typealias handling in InferableTypeOpener
For non-generic cases we can simply recurse into the underlying type,
ensuring we don't crash with a null GenericSignature. For generic
cases, ensure we bind outer generic parameters to their archetypes,
and apply the substitutions to the original underlying type to ensure
we correctly handle cases where e.g an unbound generic is passed as
a generic argument to a generic typealias.

rdar://160135085
2025-09-23 14:36:06 +01:00
swift-ci
06fb7384ce Merge remote-tracking branch 'origin/main' into rebranch 2025-09-23 03:14:56 -07:00
Hamish Knight
e64241c067 Merge pull request #84426 from hamishknight/wallsocket 2025-09-23 09:30:43 +01:00
swift-ci
9372966674 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-22 23:16:05 -07:00