Commit Graph

28382 Commits

Author SHA1 Message Date
Hamish Knight
34f809055a [Sema] Downgrade implicit self diag to warning for macro args
We previously missed diagnosing this for macro
args, fixing it turned out to be a bit more source
breaking than initially thought though, so downgrade
to a warning until Swift 7.

rdar://141963700
2025-01-10 14:36:29 +00:00
Hamish Knight
fd4c86f8f5 [Sema] NFC: Move walker out of diagnoseImplicitSelfUseInClosure
I need to add a method with a template, and C++
doesn't support that in local classes.
2025-01-10 14:36:29 +00:00
Pavel Yaskevich
e3987beffb [CSOptimizer] Literal arguments should cause score reset only for operators
Resetting score to `0.1` is intended to make sure that the
solver picks the outermost disjunction in literal chains like
`1 + 2 + 3 ...` because that would provide context to the
inner choices.

Resolves: https://github.com/swiftlang/swift/issues/78371
Resolves: rdar://142105691
2025-01-09 11:28:24 -08:00
Alejandro Alonso
f76d841540 Rename to Slab 2025-01-09 10:39:45 -08:00
Pavel Yaskevich
6c82892c3c [CSOptimizer] NFC: check whether a choice is of operator instead of whole disjunction 2025-01-09 10:39:18 -08:00
Allan Shortlidge
70a2363b97 AST: Introduce new conveniences for synthesizing AvailabilityAttrs.
This makes intent clearer at the call site and removes a lot of explicit uses
of PlatformAgnosticAvailabilityKind, which is going away.
2025-01-08 19:59:47 -08:00
Slava Pestov
c12e0a1e8f Merge pull request #78470 from slavapestov/fix-rdar141961300
Sema: Fix local property wrappers on constructor
2025-01-08 21:33:12 -05:00
Slava Pestov
df8a4c84a8 Merge pull request #78468 from slavapestov/fix-141967932
Sema: Don't remove nonisolated attribute when we diagnose it as invalid on 'lazy'
2025-01-08 18:27:40 -05:00
Doug Gregor
9bd48e0177 Merge pull request #78491 from DougGregor/strict-safety-more-cases
Strict safety more cases
2025-01-08 13:49:46 -08:00
Allan Shortlidge
9df531a1bd Merge pull request #78485 from tshortli/adopt-semantic-available-attr-part-3
AST: Remove most platform queries from `AvailableAttr`
2025-01-08 12:34:17 -08:00
Slava Pestov
c17044381e Sema: Fix local property wrappers on constructor
Fixes rdar://problem/142443421.
2025-01-08 14:31:12 -05:00
Slava Pestov
cc2048764a Sema: Clean up local property wrapper bookkeeping 2025-01-08 14:31:12 -05:00
Alejandro Alonso
61702fb813 Implement Vector literals 2025-01-08 10:35:55 -08:00
Pavel Yaskevich
8f7e71aa97 Merge pull request #78487 from xedin/Sendable-to-Any-for-lvalues
[CSApply] Sendable-to-Any: Add support for l-value to l-value and inout unsafe casts
2025-01-08 09:57:02 -08:00
Allan Shortlidge
9edd9eed9e AST: Finish adopting SemanticAvailableAttr in AvailabilityInference utilities. 2025-01-08 08:17:27 -08:00
Allan Shortlidge
05d342eb98 AST: Remove AvailableAttr::hasPlatform().
Use SemanticAvailableAttr::isPlatformSpecific() instead.
2025-01-08 08:17:27 -08:00
Allan Shortlidge
5058534805 AST: Remove AvailableAttr::prettyPlatformString(). 2025-01-08 08:17:27 -08:00
Allan Shortlidge
c2e8e3060e AST: Remove AvailableAttr::isActivePlatform(). 2025-01-08 08:17:26 -08:00
Doug Gregor
6855dc474f Uses of @exclusivity(unsafe) variables are unsafe 2025-01-08 07:03:04 -08:00
Slava Pestov
e663ad0cbd Sema: Don't remove nonisolated attribute when we diagnose it as invalid on 'lazy'
Otherwise, we'll in turn complain if the nonisolated lazy property was
@objc. This is also invalid, but the goal here is to avoid the source
break until -swift-version 6.

Fixes rdar://141967932.
2025-01-07 23:33:47 -05:00
Pavel Yaskevich
0a0a34c853 [CSApply] Add support for l-value to l-value and inout unsafe casts
`any Sendable` -> `Any` in generic argument positions should be
supported for l-value and inout types as well otherwise it won't
be possible to call setters and mutating methods.
2025-01-07 17:21:33 -08:00
Pavel Yaskevich
79f6b07961 [CSApply] Mark self parameter as inout when base/self match on deep equality
If type equality check fails we need to check whether the types
are the same with deep equality restriction since `any Sendable`
to `Any` conversion is now supported in generic argument positions
of @preconcurrency declarations. i.e. referencing a member on
`[any Sendable]` if member declared in an extension that expects
`Element` to be equal to `Any`.
2025-01-07 10:55:04 -08:00
Allan Shortlidge
f58a269512 Sema: Adopt SemanticAvailableAttr more thoroughly in TypeCheckConcurrency.cpp. 2025-01-07 07:31:29 -08:00
Allan Shortlidge
e719d71439 Sema: Adopt SemanticAvailableAttr more thoroughly in unavailability diagnostics. 2025-01-07 07:31:29 -08:00
Allan Shortlidge
c76c63712c Sema: Adopt SemanticAvailableAttr in ExprAvailabilityWalker. 2025-01-07 07:31:13 -08:00
Allan Shortlidge
a4203ed508 Sema: Adopt SemanticAvailableAttr in override availability checking. 2025-01-07 07:31:13 -08:00
Allan Shortlidge
7eb5323a31 Sema: Adopt SemanticAvailableAttr in deprecation diagnostics. 2025-01-07 07:31:13 -08:00
Allan Shortlidge
dcfe563294 AST: Remove AvailabilityInference::availableRangeAndAttr() 2025-01-07 07:31:13 -08:00
Allan Shortlidge
efa1afff11 AST: Introduce SemanticAvailableAttr::getIntroducedRange().
It replaces the overload of AvailabilityInference::availableRange() that takes
an AvailableAttr.
2025-01-07 07:31:12 -08:00
Allan Shortlidge
f1d0885458 AST: Adopt SemanticAvailableAttr in AvailabilityConstraint. 2025-01-07 07:31:12 -08:00
Allan Shortlidge
4ed62e3154 AST: Introduce Decl::getAvailableAttrForPlatformIntroduction().
It replaces `AvailabilityInference::attrForAnnotatedAvailableRange()`.
2025-01-07 07:31:12 -08:00
Hamish Knight
33bff48e92 Merge pull request #78367 from hamishknight/in-context
[Sema] Remove RecontextualizeClosures
2025-01-07 09:43:27 +00:00
Anthony Latsis
33f03f7a03 Merge pull request #78434 from AnthonyLatsis/each-pack
Sema: Do better at diagnosing missing `each`
2025-01-07 09:11:28 +00:00
Anthony Latsis
32cf2d8c2f Sema: Do better at diagnosing missing each 2025-01-07 05:22:48 +00:00
Pavel Yaskevich
b7a7839ed0 [CSSimplify] Allow any Sendable -> Any if subscript appears in preconcurrency context 2025-01-06 19:41:57 -08:00
Pavel Yaskevich
c225db473c [CSApply] NFC: Simplify coerceSelfArgumentToType
`coerceToType` can to handle l-value -> inout correctly
and report better information if coercion fails.
2025-01-06 18:11:36 -08:00
Ian Anderson
87d6979dae Merge pull request #78303 from ian-twilightcoder/clang-importer-search-paths
[ClangImporter] clang's -iframework comes before builtin usr/local/include, but Swift's -Fsystem comes after
2025-01-06 13:05:25 -08:00
Slava Pestov
2d17294d73 Merge pull request #78301 from slavapestov/remove-one-way-constraints
Sema: Remove ConstraintKind::OneWayBindParam and ConstraintKind::OneWayEqual
2025-01-05 10:38:14 -05:00
Anthony Latsis
062061e37a Merge pull request #78235 from AnthonyLatsis/aloe-vera
Sema: Minor adjustment to `BindingSet` dumping
2025-01-04 15:13:10 +00:00
Anthony Latsis
a6e5e19512 Sema: Minor adjustment to BindingSet dumping
Shorten some of the keys and format them consistently as sentence
fragments rather than identifiers.
2025-01-04 11:27:54 +00:00
Allan Shortlidge
d0f63a0753 AST: Split Availability.h into multiple headers.
Put AvailabilityRange into its own header with very few dependencies so that it
can be included freely in other headers that need to use it as a complete type.

NFC.
2025-01-03 18:36:04 -08:00
Allan Shortlidge
2c52f057df Merge pull request #78414 from tshortli/back-deployed-without-body-redux
Sema: Diagnose `@backDeployed` functions with missing bodies in swiftinterfaces
2025-01-03 15:16:44 -08:00
Allan Shortlidge
7ea778f3a0 Sema: Diagnose @backDeployed functions with missing bodies in swiftinterfaces.
A `@backDeployed` function printed in a `.swiftinterface` must have a function
body so that SILGen can emit a fallback copy to call when the back deployed
function is unavailable. Previously, the compiler would crash in SILGen when
compiling an interface containing a back deployed function without a body.

Resolves rdar://141593108.
2025-01-03 09:15:12 -08:00
Joe Groff
31b702d590 Merge pull request #78311 from jckarter/addressable-for-dependencies
Add an `@_addressableForDependencies` type attribute.
2025-01-03 07:45:43 -08:00
Pavel Yaskevich
5cac7dba79 Merge pull request #78357 from xedin/too-complex-with-count
[CSOptimizer] Few tweaks to make unapplied disjunction and literal array arguments faster
2025-01-03 00:20:40 -08:00
Joe Groff
5c4406b5e8 Add an @_addressableForDependencies type attribute.
This attribute makes it so that a parameter of the annotated type, as well as
any type structurally containing that type as a field, becomes passed as
if `@_addressable` if the return value of the function has a dependency on
the parameter. This allows nonescapable values to take interior pointers into
such types.
2025-01-02 21:33:51 -08:00
Michael Gottesman
56f38c4172 [concurrency] Add support in SILGen/SIL for emitting and calling implicit leading parameters for CallerInheritingIsolation isolation.
This does not change region isolation yet to recognize these as effectively
nonisolated.
2025-01-02 13:18:54 -08:00
Michael Gottesman
5d4239af57 [concurrency] Add new isolation kind CallerIsolationInheriting.
Right now it is basically a version of nonisolated beyond a few simple cases
like constructors/destructors where we are pretty sure we want to not support
this.

This is part of my bringup strategy for changing nonisolated/unspecified to be
caller isolation inheriting.
2025-01-02 13:18:30 -08:00
Michael Gottesman
b2a4f7e3cc [sil] Add to SIL and SILGen the ability to emit/represent implicit parameters.
I need this today to add the implicit isolated parameter... but I can imagine us
adding more implicit parameters in the future, so it makes sense to formalize it
so it is easier to do in the future.
2025-01-02 13:18:11 -08:00
Hamish Knight
4cbe481f82 Merge pull request #78377 from hamishknight/no-simplify-result
[CS] Don't simplify `FunctionResult` in `simplifyLocator`
2025-01-02 17:26:22 +00:00