Commit Graph

23281 Commits

Author SHA1 Message Date
Pavel Yaskevich
1d8536eed2 Merge pull request #84729 from xedin/rdar-161207705
[CSSimplify] Avoid simplifying dependent members until pack expansion…
2025-10-08 16:19:00 -07:00
Anthony Latsis
537353074d Merge pull request #84730 from swiftlang/jepa-main2
RequirementMachine: Diagnose unsupported value generic parameter definitions properly
2025-10-08 21:12:00 +01:00
Meghana Gupta
5e325632ed Merge pull request #84746 from meg-gupta/mutateaccessorspr
Add support for mutate accessors
2025-10-08 11:08:59 -07:00
Artem Chikin
38a8b07ac3 Merge pull request #84684 from aviralg/perf-hint/existential-any
[Performance Hints] Implement check for existential any
2025-10-08 00:19:53 -04:00
Anthony Latsis
58fa8bf762 RequirementMachine: Diagnose unsupported value generic parameter definitions properly
The flow was such that we recorded subtype constraints regardless of the
subject type's nature. Extract value generics handling out of the
devious `else if` chain, and never record any subtype constraints if the
subject type is a non-type parameter.

While we're here, generalize the diagnostic message for user-written
subtype constraints on value generic parameters and emit it
consistently, not just if the right-hand side contains a protocol type.
2025-10-08 02:13:03 +01:00
Meghana Gupta
c9a68d1e18 Add a new bit to ExtInfo to represent inout results
Move NumParams from ExtInfo to AnyFunctionType to make room in ExtInfo
2025-10-07 14:11:58 -07:00
Becca Royal-Gordon
60b3b088d5 Merge pull request #84358 from beccadax/common-concurrency 2025-10-07 12:21:50 -07:00
Hamish Knight
11d299c212 Merge pull request #84698 from hamishknight/carousel
[Evaluator] Avoid emitting duplicate "through reference here" notes
2025-10-07 20:14:52 +01:00
Aviral Goel
1cf692f116 [Performance Hints] Implement check for existential any
This commit introduces a performance hint check that warns on the use of
existential any in variable declarations, function and closure parameters and
returns, and typealiases.
2025-10-07 11:18:31 -07:00
John Hui
312caa3a82 Merge pull request #84723 from j-hui/suppress-notes
[Diagnostics] Add -suppress-notes flag
2025-10-07 11:18:22 -07:00
Max Desiatov
b545a28bd3 Add missing // REQUIRES: swift_feature_ForExpressions 2025-10-07 12:34:49 +01:00
Max Desiatov
e7aac5df12 for expressions scaffolding, making constraints work 2025-10-07 11:16:54 +01:00
Pavel Yaskevich
c278717887 [CSSimplify] Avoid simplifying dependent members until pack expansions in the based are bound
Dependent members cannot be simplified if base type contains unresolved
pack expansion type variables because they don't give enough information
to substitution logic to form a correct type. For example:

```
protocol P { associatedtype V }
struct S<each T> : P { typealias V = (repeat (each T)?) }
```

If pack expansion is represented as `$T1` and its pattern is `$T2`, a
reference to `V` would get a type `S<Pack{$T}>.V` and simplified version
would be `Optional<Pack{$T1}>` instead of `Pack{repeat Optional<$T2>}`
because `$T1` is treated as a substitution for `each T` until bound.

Resolves: rdar://161207705
2025-10-07 00:20:51 -07:00
Henrik G. Olsson
3bc17bdd2f Merge pull request #84722 from hnrklssn/conditional-span-module-map
Move `span` to conditional header in libstdc++ module map
2025-10-06 22:09:07 -07:00
eeckstein
401a2ac2bc Merge pull request #84704 from eeckstein/closure-specialization
ClosureSpecialization: support for OSSA and a big overhaul
2025-10-07 06:59:08 +02:00
Hamish Knight
9883477c02 Merge pull request #84699 from hamishknight/meta-error
[CS] Improve diagnostics for non-metatype `type(of:)` contextual type
2025-10-07 02:49:10 +01:00
John Hui
d68ca8de1e [Diagnostics] Add -suppress-notes flag
We already have -suppress-warnings and -suppress-remarks; this patch
adds support for suppressing notes too. Doing so is useful for -verify
tests where we don't really care about the emitted notes.
2025-10-06 17:05:57 -07:00
Henrik G. Olsson
5519be8b7c Move span to conditional header in libstdc++ module map
`span` is not available in all versions of libstd++, so make it a
conditional header. Also adds other missing c++20 headers.

Fixing this triggered an assert when importing a constant initialized
`wchar_t` variable, so that is also fixed. The reason is that `wchar_t`
is mapped to `Unicode.Scalar`, which cannot be directly initialized by
integer literals in Swift, triggering an assert when looking up the
protocol conformance for `_ExpressibleByBuiltinIntegerLiteral`.

rdar://162074714
2025-10-06 16:02:35 -07:00
Andrew Trick
7818b8c0df Merge pull request #84702 from atrick/builtin-nonescapable
Allow Builtin.Load/Take -> ~Escapable
2025-10-06 14:27:59 -07:00
Hamish Knight
d65f28984a [CS] Improve diagnostics for non-metatype type(of:) contextual type
Emit a custom diagnostic for this case, and handle holes.
2025-10-06 21:45:48 +01:00
Andrew Trick
c2171ea9b0 Merge pull request #84703 from atrick/lifedep-diag-init
Lifetimes: add a diagnostic note for implicit accessors
2025-10-06 12:29:51 -07:00
Hamish Knight
6d7d1d78d6 Merge pull request #84695 from hamishknight/typewriter
[AST] Canonicalize original type for ErrorType
2025-10-06 17:23:55 +01:00
Erik Eckstein
8efafc7e3b Optimizer: remove the -experimental-swift-based-closure-specialization option 2025-10-06 12:02:48 +02:00
Andrew Trick
c494124d11 Allow Builtin.Take -> ~Escapable 2025-10-05 20:17:47 -07:00
Andrew Trick
771e9b522e Lifetimes: add a diagnostic note for implicit accessors
Lifetime diagnostics may report an error within an implicit initializer or
accessor. The source location is misleading in these cases and causes much
consternation.
2025-10-05 20:16:44 -07: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
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
Henrik G. Olsson
ed4f058c01 Merge pull request #84507 from hnrklssn/swiftify-import-as-method
[Swiftify] Add support for free functions imported as instance methods
2025-10-04 00:40:00 -07: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
Meghana Gupta
ea0e0173b4 Merge pull request #84595 from meg-gupta/moreborrowaccessors
Extend borrow accessor support
2025-10-03 11:14:49 -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
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
Henrik G. Olsson
87642d499a [Swiftify] Add support for free functions imported as instance methods
This adds support for attaching safe interop wrappers to functions
explicitly imported as instance methods using swift_name.

rdar://156288883
2025-10-02 16:37:40 -07:00
Daniil Kovalev
a9e43a487e Bridging: Fix typo-related bug in isValid property of swift::Identifier (#84649)
`isValid` should be computed as `nonempty()`, not `empty()`.

See commit 0e0fbc4160 introducing this bridge.
2025-10-02 16:19:21 -07:00
Artem Chikin
96ee032d70 Merge pull request #84578 from artemcm/SPA-Init
[Performance Hints] Add simple check for returning of values of array and dictionary type
2025-10-02 19:11:57 -04: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
Artem Chikin
7c74890bd8 [Performance Hints] Add simple check for returning of values of array and dictionary type
This check will run on each type-checked primary input of the current compilation and emit a warning diagnostic for all discovered occurences of this code pattern when the performance hint diagnostic is enabled
2025-10-02 10:31:13 -07:00
Arnold Schwaighofer
cfd0d6af35 Merge pull request #84624 from aschwaighofer/inline_always_error_non_final_class_methods
Error on usage of `@inline(always)` on non-final class methods
2025-10-02 08:53:21 -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
Meghana Gupta
5e3ff1ea39 [NFC] Add hasGuaranteedResult api 2025-10-02 07:18:29 -07:00
Sima Nerush
7122a11b43 Merge pull request #79895 from simanerush/allow-explicit-nonisolated-for-lazy-and-prop-wrappers
[Concurrency] Allow explicit 'nonisolated' on lazy properties and properties with property wrappers if they are a member of a non-'Sendable' type.
2025-10-01 15:53:43 -07:00
Arnold Schwaighofer
7ceebbee22 Error on usage of @inline(always) on non-final class methods 2025-10-01 09:19:32 -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