Commit Graph

21 Commits

Author SHA1 Message Date
Michael Gottesman
3ed4059a60 [sema] Change non-sendable -> non-Sendable in diagnostics.
This matches send non sendable but importantly also makes it clear that we are
talking about something that doesn't conform to the Sendable protocol which is
capitalized.

rdar://151802975
2025-05-22 11:37:58 -07:00
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01:00
Holly Borla
14ced21afa [Concurrency] Update tests for downgraded warning. 2024-01-26 10:55:31 -08:00
Doug Gregor
f234e538b5 Introduce and fix tests for @Sendable in nested positions 2022-09-16 15:09:45 -07:00
Becca Royal-Gordon
ecdd42f20c Make @preconcurrency import hide sendable variance
When the conformance checker and override checker detect a difference in a function type’s @Sendable attribute that varies in an illegal way, they now check if the protocol/base class was imported with an @preconcurrency import, and either limit the diagnostic or suggest adding @preconcurrency to the import as appropriate.

Completes rdar://91109455.
2022-04-08 13:08:39 -07:00
Becca Royal-Gordon
4ab523378a Warn about incorrect Sendable for witnesses 2022-04-05 16:46:48 -07:00
Becca Royal-Gordon
bbec066347 Warn about incorrect Sendable for overrides 2022-04-05 13:50:38 -07:00
Becca Royal-Gordon
784d760419 Correct @Sendable variance for witnesses
It previously treated parameters and return types as the same, instead of properly handling variance.
2022-04-05 13:50:38 -07:00
Becca Royal-Gordon
07d0cfaffc Allow overloads with varying @Sendable func types
Specifically, an override can validly have a parameter type that is not `@Sendable` or a function type that is `@Sendable` even if that contradicts the base declaration. That’s becuase it’s always valid to provide a sendable function when one is not actually needed, but not vice versa.
2022-04-05 13:50:37 -07:00
Doug Gregor
365f0afa9f Downgrade concurrency-related function type errors in existing code
When in "existing" Swift code that is Swift 5.x and has not adopted
concurrency, allow mismatches in function types that only involve
ABI-neutral concurrency changes (e.g., adding `@Sendable` or removing
a global actor) by downgrading the diagnostic to a warning. This
improves the story for incremental adoption of concurrency in an
existing code base.

As part of this, generalize the facility for downgrading an error to a
warning when performing diagnostics in the constraint solver, using the
new diagnostic behavior limits rather than duplicating diagnostics.
2021-12-02 10:33:01 -08:00
Konrad `ktoso` Malawski
703595e396 [Concurrent] Warnings/errors should use "sendable" not "concurrent"
Resolves rdar://83416205
2021-09-23 12:45:07 +09:00
Doug Gregor
52096a640e SE-0302: Rename ConcurrentValue/@concurrent to Sendable/@Sendable. 2021-03-18 23:48:21 -07:00
Doug Gregor
7c336ea19a Add support for @concurrent attribute on closures. 2021-02-16 22:19:47 -08:00
Doug Gregor
184b150015 Allow the @concurrent function attribute without the concurrency flag 2021-02-12 16:36:12 -08:00
Doug Gregor
6dd1c4768a [Concurrency] Put the flow-sensitive concurrent captures check behind a flag
We're not quite ready to commit to the flow-sensitive check that would
allow a concurrent function to read from a mutable local capture so
long as the captured variable wasn't changed after the point of
capture. Put it behind a flag and implement the more restrictive rule
(no access to mutable local captures in concurrent code). We can relax
it later.
2021-02-11 11:43:07 -08:00
Doug Gregor
388fd1fed9 [Concurrency] Fix checking of captures in concurrent closures.
inout expressions can occur as children of "load" expressions, so
ensure that we (1) treat them as loads, semantically, and (2) don't
visit them multiple times.
2021-02-05 13:55:18 -08:00
Doug Gregor
a554ad632b [Concurrency] Diagnose mutating accesses to locals from concurrent code.
Replace the existing warning about any access to a local variable from
concurrently-executing code with a more tailored error:
concurrently-executing code may read a mutable varable, but cannot
modify it. This is safe so long as we either always do by-value
captures in concurrent closures or we ensure that no mutation of that
variable can occur after the point of capture.

We'll follow up with one of those. For now... be careful out there.

Since we're promoting this to an error, narrow it down to concurrent
closures and local functions, dropping the assumption that escaping
closures "may execute concurrently."
2021-01-29 14:27:24 -08:00
Doug Gregor
6d086d4d9c Add support for @concurrent on function declarations 2021-01-28 00:50:40 -08:00
Doug Gregor
5129d82c5b Add more tests for @concurrent function types 2021-01-27 21:05:50 -08:00
Doug Gregor
b77ba9a77f [Concurrency] Infer @concurrent on closures from contextual type 2021-01-27 16:00:39 -08:00
Doug Gregor
ba8819eb58 [Concurrent] Introduce concurrent function types.
Introduce `@concurrent` attribute on function types, including:
* Parsing as a type attribute
* (De-/re-/)mangling for concurrent function types
* Implicit conversion from @concurrent to non-@concurrent
- (De-)serialization for concurrent function types
- AST printing and dumping support
2021-01-27 14:22:32 -08:00