Commit Graph

104 Commits

Author SHA1 Message Date
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Michael Gottesman
df2844d267 [concurrency] Cleanup verify-additional-prefix usage in tests.
This includes a bunch of fixes. It is not exhaustive but fit my time boxed time
period I set aside to look at this today.

A quick non-exhaustive list:

1. I removed unnecessary verify-additional-prefix lines.
2. Split tests with typechecker error and non-typechecker error components.
3. Removed complete- lines that we used when testing w/without send
non sednable.
4. Translated complete-and-tns- lines to be just complete- since they are just
testing strict-concurrency=complete and we are not testing complete without
send non sendable anymore.
2025-08-12 10:56:02 -07:00
Konrad 'ktoso' Malawski
03774d245a fix some tests due to diagnostic rewording 2025-07-15 11:16:13 +09:00
Konrad 'ktoso' Malawski
f52f445358 [Concurrency] add fixit to add final to non-sendable class -> Sendable
The previous message was just suggesting unchecked Sendable, but instead
we should be suggesting to add final to the class. We also don't
outright suggest using unchecked Sendable -- following
https://github.com/swiftlang/swift/pull/81738 precedent.

Resolves rdar://155790695
2025-07-15 10:42:25 +09:00
Michael Gottesman
a6edf4fb90 [rbi] Convert all rbi tests to run also in NonisolatedNonsendingByDefault.
Going to update the tests in the next commit. This just makes it easier to
review.
2025-07-02 12:13:37 -07:00
Pavel Yaskevich
3495c61840 [Diagnostics] Use contains instead of has when non-Sendable type appears inside of a member type 2025-06-05 11:14:55 -07:00
Pavel Yaskevich
e24196e365 [Concurrency] Clean-up duplicate code in checkSendableInstanceStorage 2025-06-05 11:13:37 -07:00
Pavel Yaskevich
9e562881fe [TypeChecker] Improve diagnostics for access to actor-isolated values outside of the actor
Replaces generic `expression is 'async' but is not marked with 'await`
diagnostic with a tailed one for cases where there is an access to an
actor-isolated value outside of its actor without `await` keyword.

This makes the diagnostics for async and sync contexts consistent
and actually identifies a problem instead of simply pointing out
the solution.

Resolves: rdar://151720646
2025-05-23 00:20:18 -07:00
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
Michael Gottesman
205038b1b0 [rbi] Simplify some logic that got confused so that passing an actor isolated value to a callee that is isolated ot the same actor is not considered a send.
The logic here got confused over time. This simplifies the logic and ensures
that we do not send a value if it is in the same isolation domain as the callee.

The one interesting side effect of this is that in a few tests, due to the logic
being confused, we were emitting use-after-send errors for global actor isolated
values that were passed to a function that was global actor isolated to the same
actor and then used later locally. The error was sending 'X'-isolated a to
'X'-isolated function causes race against nonisolated local uses. In truth, this
error is misleading and the only error that we should be emitting in such a case
is the error about moving an isolated value into a non-isolated context (which
we already emit).

rdar://132932382
2025-04-18 09:58:10 -07:00
Doug Gregor
3f1a6c84c2 Update tests for isolated conformances being enabled by default 2025-04-13 15:41:57 -07:00
Anthony Latsis
99f63ed933 DiagnosticEngine: Support TypeAttribute diagnostic arguments 2025-04-03 01:52:38 +01:00
Anthony Latsis
eeb991122a [NFC] Switch from backticks to quotes in several diagnostics 2025-01-29 07:49:27 +00:00
Michael Gottesman
c48a9cc72f test updates 2024-12-02 16:54:12 -05:00
Allan Shortlidge
c02fc4724d Tests: Remove -disable-availability-checking from many Concurrency tests.
Instead, use the `%target-swift-5.1-abi-triple` substitution to compile the tests
for deployment to the minimum OS versions required for use of _Concurrency APIs.
2024-10-18 16:21:51 -07:00
Michael Gottesman
4bb2e4f3b1 [region-isolation] Improve the error we emit for closure literals captured as a sending parameter.
Specifically:

I changed the main error message to focus on the closure and that the closure
is being accessed concurrently.

If we find that we captured a value that is the actual isolation source, we
emit that the capture is actually actor isolated.

If the captured value is in the same region as the isolated value but is not
isolated, we instead say that the value is accessible from *-isolated code or
code within the current task.

If we find multiple captures and we do not which is the actual value that was
in the same region before we formed the partial apply, we just emit a note on
the captures saying that the closure captures the value.

I changed the diagnostics from using the phrase "task-isolated" to use some
variant of accessible to code in the current task.

The idea is that in all situations we provide a breadcrumb that the user can
start investigating rather than just saying that the closure is "task-isolated".

From a preconcurrency perspective, I made it so that we apply the preconcurrency
behavior of all of the captures. This means that if one of the captures is
preconcurrency, we apply the preconcurrency restriction to the closure. This is
one step towards making it so that preconcurrency applies at the region level...
we just are not completely there yet.

rdar://133798044
2024-08-14 10:37:31 -07:00
Holly Borla
93191020bc Merge pull request #75687 from hborla/sendable-param-diagnostics
[Concurrency] Split up the non-`Sendable` diagnostics and improve wording.
2024-08-05 21:21:33 -07:00
Holly Borla
976d92143c [Concurrency] Split up the non-Sendable property diagnostics and improve
wording.
2024-08-05 14:56:45 -07:00
Holly Borla
9f0b2ec746 [Concurrency] Minor wording change to witness and override Sendable diagnostics. 2024-08-05 10:05:08 -07:00
Holly Borla
bd1653e497 [Concurrency] Split up the non-Sendable result diagnostics and improve
wording.
2024-08-05 09:56:11 -07:00
Holly Borla
933f8eb8a0 [Concurrency] Split up the non-Sendable argument diagnostics and improve
wording.

Splitting up the diagnostic into separate diagnostics based on the reference
kind is easier for me to read. The wording of the error message now puts
the problem -- crossing an isolation boundary -- at the center of the message,
and attempts to clarify how the value crosses an isolation boundary. E.g. for
the witness diagnostics, the value crosses an isolation boundary when calling
the witness through the protocol requirement in generic code.

This change does not add any additional information to the diagnostics, but it'd
be valuable to show both the source and destination isolation.
2024-08-05 08:23:30 -07:00
Michael Gottesman
9c4da1ffb6 Merge pull request #75597 from gottesmm/incremental-diagnostics
[region-isolation] Incremental diagnostic updates
2024-08-02 15:10:34 -07:00
Michael Gottesman
e7e035f60c [region-isolation] Convert the transfer non sendable typed error to be a new short-error, long-note form error.
I also messed with the text a little bit.

This eliminates the last of the old style diagnostics.
2024-07-31 13:10:02 -07:00
Holly Borla
d40663dd66 [Concurrency] Flip the implicitly async select in a concurrency error.
This diagnostic was presenting "implicitly async" for explicitly async calls,
and vice versa, because the `select` was incorrect.
2024-07-31 06:46:07 -07:00
Holly Borla
ee2dd82d56 Merge pull request #75235 from rofle100lvl/change_note_main_actor_variables
Change note for non marked with main actor global variables
2024-07-20 11:43:29 -07:00
Горбенко Роман
2c1e45a598 Changed note main actor variables 2024-07-20 02:39:33 +02:00
Holly Borla
22db5634ef Merge pull request #75359 from hborla/unavailable-sendable-restated
[Concurrency] Don't warn about re-stating inherited unavailable conformances to `Sendable`.
2024-07-19 12:32:07 -07:00
Michael Gottesman
ebedf63138 [region-isolation] Do not squelch use-after-transfer error even if the value is isolated to the same actor.
rdar://132074953
2024-07-19 02:25:53 -07:00
Michael Gottesman
3aee7da4b9 [region-isolation] Remove expected-complete-warning from a test. It is dead. 2024-07-19 02:25:53 -07:00
Holly Borla
69b2435bab [Concurrency] Don't warn about re-stating inherited unavailable conformances
to `Sendable`.

The unavailability check was not using the root conformance, which is where
the extension declaration with the unavailability attribute is for inherited
conformances, leading to bogus warnings about re-stating unchecked conformances
to `Sendable`.
2024-07-18 20:44:28 -07:00
Timur Guliamov
dd221a8e01 Added fix-it to add the @unchecked Sendable conformance if it is not re-stated (#75233)
Co-authored-by: Timur Guliamov <tplaymeow@MacBook-Pro-Timur-2.local>
2024-07-18 14:14:12 +09:00
Michael Gottesman
474aa47732 [concurrency] Standardize sending of non-isolated -> nonisolated to match the keyword 'nonisolated'.
rdar://130827967
2024-06-29 18:09:38 -07:00
Michael Gottesman
4697546e09 [sending] Mark Task.init,detached, and friends as sending methods instead of __owned @Sendable so we can capture non-isolated values. 2024-06-21 02:24:03 -07:00
Holly Borla
1a07152ee0 [NFC][Concurrency] Remove -disable-region-based-isolation-with-strict-concurrency
from tests.
2024-06-19 20:48:59 -07:00
Doug Gregor
5a0e70a2bc Update diagnostic text to address code review feedback 2024-05-20 22:06:40 -07:00
Doug Gregor
d4ce618e2f Provide more Fix-It guidance for concurrency-unsafe global variables (SE-0412)
When diagnosing a concurrency-unsafe global or static variable, provide
Fix-Its with specific guidance and advice. This is intended to aid the
workflow for folks enabling strict concurrency checking or Swift 6.
There are up to three Fix-Its attached to a diagnostic about
concurrency-unsafe global/static variables:

* convert 'global' to a 'let' constant to make the shared state
immutable, which replaces `var` with `let`
* restrict 'global' to the main actor if it will only be accessed from the
main thread, which adds `@MainActor`
* unsafely mark %0 as concurrency-safe if all accesses are protected
by an external synchronization mechanism, which adds `nonisolated(unsafe)`

I fretted over two things before deciding on this path:

1. For the second note, the reality is that any global actor will
suffice, but `@MainActor` is orders of magnitude more common than any
other global actor, so "common case convenience" wins over "precise
but less useful.
2. For the third note, `nonisolated(unsafe)` should only be used
sparingly, and surfacing it via Fix-It could cause overuse. However,
developers need to know about it, and this is how we do that. It comes
last in the list of notes (after the better options) and says "unsafe"
in not one but two places.
2024-05-19 15:05:39 -07:00
Doug Gregor
fc85f98460 Respect @preconcurrency in check of nonisoalted let variables 2024-05-16 21:47:39 -07:00
Michael Gottesman
b3e837c16c [region-isolation] Enable region isolation by default with strict-concurrency.
I added a disable flag -disable-region-based-isolation-with-strict-concurrency
so that we do not need to update the current tests. It is only available when
asserts are enabled to ensure users cannot use it.

rdar://125918028
2024-04-04 13:07:32 -07:00
Michael Gottesman
99e3f7fb13 [region-isolation] Make RegionBasedIsolation an upcoming feature for swift 6.
To make the tests pass, I had to teach sil-opt how to setup upcoming features
since it did not know how to parse them.

rdar://124100266
2024-03-05 15:15:14 -08:00
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Holly Borla
eba4545536 [Concurrency] Warn if implied @unchecked Sendable conformances are not
re-stated.
2024-02-23 23:59:16 -08:00
Holly Borla
c98d93d75f Merge pull request #70909 from hborla/nonisolated-nonsendable 2024-01-28 13:10:23 -08:00
Holly Borla
14ced21afa [Concurrency] Update tests for downgraded warning. 2024-01-26 10:55:31 -08:00
Holly Borla
009d7d0c70 [Concurrency] nonisolated can only be applied to actor properties with
`Sendable` type.
2024-01-26 08:54:28 -08:00
Nate Chandler
92a495b1a8 [Test] Add new expected warnings.
Two changes landed simultaneously that resulted in unexpected warnings.
2024-01-25 16:16:39 -08:00
Angela Laar
2ae159be4a Merge pull request #70858 from angela-laar/actor-isolated-properties-for-classes
[Sema] Classes with actor-isolated mutable properties should conform to Sendable
2024-01-25 13:19:09 -08:00
Angela Laar
c779f37154 [Sema] Skip Sendable checking for actor-isolated stored properties 2024-01-17 11:08:54 -08:00
Angela Laar
662e30eaf4 [Sema] Sendable classes should allow actor-isolated mutable properties 2024-01-12 16:19:34 -08:00
Holly Borla
d37b9763b6 [Concurrency] Promote StrictConcurrency to an upcoming feature flag. 2024-01-11 21:23:25 -08:00
Pavel Yaskevich
dbf1146963 [Concurrency] NFC: Switch tests to use -strict-concurrency=complete instead of -warn-concurrency 2023-12-08 14:10:51 -08:00