Commit Graph

28234 Commits

Author SHA1 Message Date
Pavel Yaskevich
f0bdecde34 Merge pull request #80872 from xedin/rdar-149107104
[TypeChecker] Allow closures to assume `nonisolated(nonsending)`
2025-04-17 13:08:58 -07:00
Nate Chandler
c28d295375 [CoroutineAccessors] Require underscored override.
If an overridden decl requires an underscored accessor, then the derived
decl requires one too.  Otherwise dispatch to a less-derived instance
could bind to the underscored accessor which lacks an override.

rdar://149352777
2025-04-17 09:23:24 -07:00
Nate Chandler
c72b1274cf [NFC] Sema: Extract static function.
In preparation for a recursive call and an additional private parameter.
2025-04-17 09:23:23 -07:00
Nate Chandler
d298602496 [NFC] CoroutineAccessors: Delete TODO.
Add a test case.
2025-04-17 09:23:23 -07:00
stzn
765f8acf7b Check sending in the process of diagnosing NonSendable types 2025-04-17 20:17:36 +09:00
nate-chandler
898075a95e Merge pull request #80828 from nate-chandler/rdar148783895
[CoroutineAccessors] Only reference when available
2025-04-16 20:38:31 -07:00
Pavel Yaskevich
3de72c5452 [TypeChecker] Allow closures to assume nonisolated(nonsending)
Always infer `nonisolated(nonsending)` from context directly on
a closure unless the closure is marked as `@concurrent`, otherwise
the closure is not going to get correct isolation and going to hop
to the wrong executor in its preamble.

Resolves: rdar://149107104
2025-04-16 17:19:21 -07:00
Hamish Knight
b36eb57dbd [Sema] Downgrade noasync diagnostic to warning for closure macro args
Downgrade to a warning until the next language mode. This is
necessary since we previously missed coercing macro arguments to
parameter types, resulting in cases where closure arguments weren't
being treated as `async` when they should have been.

rdar://149328745
2025-04-16 19:22:52 +01:00
Hamish Knight
14bd41159e NFC: Abstract away the use of '7' to represent the next language mode
Introduce `Version::getFutureMajorLanguageVersion` to make it easier
to find clients that will need to be updated once we have a new
language mode.
2025-04-16 19:22:52 +01:00
Hamish Knight
b6a09d1b33 Reapply: [CS] Make sure macro arguments go through coerceCallArguments
Previously we would avoid rewriting the arguments in CSApply, but
that can result in incorrect behavior in MiscDiagnostics passes, e.g
incorrectly treating all closure arguments as escaping. Make sure
we rewrite the arguments as we would in regular type-checking.

rdar://148665502
2025-04-16 19:22:52 +01:00
Hamish Knight
aa2bb0c9ea Merge pull request #80830 from swiftlang/revert-80583-macro-arg-apply
Revert "[CS] Make sure macro arguments go through `coerceCallArguments`"
2025-04-16 19:19:38 +01:00
Alexis Laferrière
a6beaf8deb Merge branch 'main' into cdecl-global-function-checking 2025-04-16 11:19:37 -07:00
Nate Chandler
7697a49ee9 [CoroutineAccessors] Only reference when available
Don't bind references to storage to use (new ABI) coroutine accessors
unless they're guaranteed to be available.  For example, when building
against a resilient module that has coroutine accessors, they can only
be used if the deployment target is >= the version of Swift that
includes the feature.

rdar://148783895
2025-04-15 21:13:57 -07:00
Nate Chandler
347689fb30 [NFC] AST: Extract helper method.
Several callers of `AbstractStorageDecl::getAccessStrategy` only cared
about whether the the access would be via physical storage.  Before
adding more arguments to `getAccessStrategy` for which such callers
would have to pass a sentinel value, add a convenience method for this.
2025-04-15 20:45:37 -07:00
Hamish Knight
475e02a381 Revert "[CS] Make sure macro arguments go through coerceCallArguments" 2025-04-15 18:44:14 +01:00
Alejandro Alonso
79a51dfcc1 Move resolving param type to CSApply 2025-04-14 15:33:08 -07:00
Alejandro Alonso
ae355007fc Store TypeRepr in TypeValueExpr 2025-04-14 15:33:08 -07:00
Alejandro Alonso
a884e5153d Don't ask for the typechecked body in featureset 2025-04-14 15:33:08 -07:00
Alejandro Alonso
b3f3dd79cf Handle dynamically accessing the static member from type(of:) 2025-04-14 15:32:46 -07:00
Alejandro Alonso
b34b6e58e0 Make it an error to redeclare properties with the same name as a value generic
Update value_generics.swift
2025-04-14 15:32:45 -07:00
Alejandro Alonso
1aaf2c9d29 Allow value generics to show up as static members 2025-04-14 15:32:43 -07:00
Doug Gregor
88d630446c [Constraint solver] Delay Sendable on static method references involving possibly-nonsendable metatypes
Thank you, Pavel!
2025-04-14 10:19:11 -07:00
Doug Gregor
c7c152b14c Downgrade more sendability errors involving metatypes to warnings 2025-04-14 08:25:27 -07:00
Doug Gregor
95b18d3482 Downgrade sendability errors to warnings when they involve non-Sendable metatypes
The introduction of non-Sendable metatypes in Swift 6.2 (via SE-0470)
will break some existing Swift 6 code. Downgrade concurrency errors
involving non-Sendable metatypes to warnings until some future
language mode to ease the transition.
2025-04-13 22:46:52 -07:00
Doug Gregor
3ed1d6c390 [SE-0470] Teach @Sendable inference on static methods about non-sendable metatypes
The code that determines whether a reference to a static method (that
is not a call) assumed that metatypes were always Sendable. This is no
longer the case, so update this code to go through the normal Sendable
checking on the metatype.
2025-04-13 15:42:04 -07:00
Doug Gregor
f09cdc2893 Fix deserialization assertion involving isolated conformances 2025-04-13 15:42:00 -07:00
Doug Gregor
e4f1b62c57 Fix crash involving captured-type checking for sendable metatypes 2025-04-13 15:41:59 -07:00
Doug Gregor
3380331e7e [SE-0470] Enable isolated conformances by default
The IsolatedConformances feature moves to a normal, supported feature.
Remove all of the experimental-feature flags on test cases and such.

The InferIsolatedConformances feature moves to an upcoming feature for
Swift 7. This should become an adoptable feature, adding "nonisolated"
where needed.
2025-04-13 15:41:53 -07:00
Doug Gregor
e8b3065293 [SE-0470] Downgrade some isolated conformance-related errors to warnings in Swift 5 2025-04-13 15:40:08 -07:00
Doug Gregor
92774e0a3c Move generic signature check for isolated conformances into GenericSignatureImpl
This is going to need a proper implementation in the requirement
machine. For the moment, provide a slightly-less-broken implementation
but leave a test case where we incorrectly accept racey code.
2025-04-13 15:40:02 -07:00
Pavel Yaskevich
0caa9b54d8 Merge pull request #80668 from xedin/se-0461-renamings
[SE-0461] Replace `@execution(...)` with `@concurrent` and `nonisolated(nonsending)`
2025-04-12 11:31:15 -07:00
Pavel Yaskevich
5022847436 Merge pull request #80750 from xedin/prune-should-skip-already-disabled
[CSStep] Overload pruning should skip previously disabled choices
2025-04-11 16:26:15 -07:00
Pavel Yaskevich
3906980f58 [AST] NFC: Add a convenient way to create implicit NonisolatedAttrs 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
9da457d129 [Sema/SILGen] NFC: Remove all mentions of @execution from comments 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
07ff063ae3 [AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
2025-04-11 15:59:25 -07:00
Pavel Yaskevich
54b62ae983 [AST/Parse] Implement nonisolated(nonsending) type modifier 2025-04-11 15:59:25 -07:00
Pavel Yaskevich
b1ffa063b6 [AST/Sema] Intoduce nonisolated(nonsending) as a replacement for @execution(caller) 2025-04-11 15:57:11 -07:00
stzn
f8abb1bb00 [Sema]Skip Sendable conformance check when sending are added to parameters or return types of an actor-isolated function 2025-04-12 05:11:54 +09:00
Pavel Yaskevich
4b8c8e7d72 [AST/Sema] Replace @execution(concurrent) with @concurrent 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
318c4150f3 [AST/Sema] Support for @concurrent attribute in type context 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
2704ab7337 [AST/ASTGen] Introduce @concurrent attribute to replace @execution(concurrent) spelling 2025-04-11 12:08:29 -07:00
Pavel Yaskevich
1a3af5c91d [Diagnostics] Adjust @execution(...) diagnostic to take DeclAttribute or StringRef
It has been decided to split the attribute into `@concurrent` and
`nonisolated(nonsending`. Adjusting diagnostics to accept the attribute
makes the transition easier.
2025-04-11 12:08:29 -07:00
Alexis Laferrière
ae6bf75378 Sema: Basic type-checking of @cdecl on global functions
This implements basic checks on the validity of the @cdecl attribute and
ensures the parameters and result types are representable in C. Many
more diagnostics will need to be updated to verify full representability
in C.
2025-04-11 11:34:40 -07:00
Alexis Laferrière
02b5998536 Parser: Intro @cdecl attribute and gate it behind feature flag CDecl 2025-04-11 11:34:39 -07:00
Becca Royal-Gordon
1445b819d0 Merge pull request #80476 from beccadax/implement-this
Stub fix-its for missing objcImpl requirements
2025-04-10 16:55:19 -07:00
Pavel Yaskevich
5eeaaf0020 [CSStep] Overload pruning should skip previously disabled choices
This should be a no-op for operators today expect that we found
a case were C++ imported operator that had a label for the second
argument which disabled the overload choice early and attempted
to disable it again here which breaks CSTrail because pruned
choices are re-enabled once disjunction checking is complete.
2025-04-10 16:13:13 -07:00
Pavel Yaskevich
cad2df3d5c [Concurrency] Downgrade non-Sendable type captures to warnings if closure is in @preconcurrency context
The original check examined only the immediate closure, but it's
possible that the closure happens to be in a preconcurrency context
which also requires a downgrade.

Resolves: rdar://148996589
2025-04-10 13:54:51 -07:00
Becca Royal-Gordon
9a1f6aeb8a Tweak missing impl diagnostic for async members
The diagnostic mentions both possible names, but only provides a stub for the `async` variant.
2025-04-09 16:48:42 -07:00
Becca Royal-Gordon
0cfda873b6 Suggest stub stored properties where possible
When generating a stub fix-it for a protocol conformance or implementation extension, Swift will now evaluate whether the context allows the declaration of stored properties and, if so, will suggest one. It will also use the `let` keyword instead of `var` if the property has no setter.
2025-04-09 16:48:41 -07:00
Alexis Laferrière
031ec43f8b Sema: Requestify most checks on @_cdecl 2025-04-09 11:26:05 -07:00