Commit Graph

25 Commits

Author SHA1 Message Date
Anthony
c9b17383c8 Grammatical corrections for compound modifiers 2025-04-24 09:21:32 +02:00
Doug Gregor
3f1a6c84c2 Update tests for isolated conformances being enabled by default 2025-04-13 15:41:57 -07:00
Doug Gregor
1b1f28decb Tighten up diagnostics wording a bit 2025-03-20 22:13:19 -07:00
Doug Gregor
9ea735b9ed Rework diagnostics for conformance isolation failures
A protocol conformance can be ill-formed due to isolation mismatches
between witnesses and requirements, or with associated conformances.
Previously, such failures would be emitted as a number of separate
errors (downgraded to warnings in Swift 5), one for each witness and
potentially an extra for associated conformances. The rest was a
potential flood of diagnostics that was hard to sort through.

Collect all of the isolation-related problems for a given conformance
together and produce a single error (downgraded to a warning when
appropriate) that describes the overall issue. That error will have up
to three notes suggesting specific courses of action:
* Isolating the conformance (when the experimental feature is enabled)
* Marking the witnesses as 'nonisolated' where needed
*

The diagnostic also has notes to point out the witnesses/associated
conformances that have isolation problems. There is a new educational
note that also describes these options.

We give the same treatment to missing 'distributed' on witnesses to a
distributed protocol.
2025-03-20 21:23:16 -07:00
Doug Gregor
cd99fb57fd [Diagnostics] Remove unhelpful notes from witness-isolation diagnostics
When diagnosing an isolation mismatch between a requirement and witness,
we would produce notes on the requirement itself suggesting the addition of
`async`. This is almost never what you want to do, and is often so far
away from the actual conforming type as to be useless. Remove this note,
and the non-function fallback that just points at the requirement, because
they are unhelpful.

This is staging for a rework of the way we deal with conformance-level
actor isolation problems.
2025-03-19 17:18:52 -07:00
Anthony Latsis
f85eb97337 ConformanceChecker: Make actor_isolated_witness call out the protocol 2025-01-14 14:49:22 +00:00
Holly Borla
86f3fe1680 [Concurrency] Don't infer actor isolation from inherited conformances.
If a conformance is inherited from a superclass, the isolation
of the subclass should be inferred directly from the superclass.
If the superclass has opted out of global actor inference from a
protocol, such as by conforming to the protocol in an extension,
then the subclass should not infer isolation from the protocol.
2024-07-09 19:43:40 -07: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
Holly Borla
13f0c0c953 [Concurrency] Infer protocol isolation from superclass requirements.
Actor isolation on protocols was already inferred from inherited protocols,
but we were missing inference from a required superclass.
2024-06-20 21:24:52 -07:00
Michael Gottesman
de85b79423 [concurrency] Make GlobalActorIsolatedTypesUsability an upcoming swift 6 feature.
rdar://118244451
2024-05-13 18:40:58 -07:00
Doug Gregor
90341b202b Infer protocol isolation from its inherited protocols.
We somehow missed this inference rule. Put it behind SE-0434's
`GlobalActorIsolatedTypesUsability` flag. Fixes rdar://127843050.
2024-05-10 13:10:11 -07:00
Holly Borla
23c16f8d75 [NFC] Remove a redundant run line from concurrency test. 2024-04-23 15:43:14 -07:00
Holly Borla
a6d9c15fb3 [Concurrency] Don't error on isolated property wrapper initializers inside
MainActor-isolated structs.
2024-04-21 10:01:31 -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
f1cd9cb422 [Test] Remove REQUIRES: asserts from tests that use -swift-version 6. 2024-02-13 07:13:35 -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
Holly Borla
275d78342f [Concurrency] Compute actor isolation for var decls before checking
decl attributes.
2023-12-04 17:36:59 -08:00
Michael Gottesman
cb46851194 [region-isolation] Rename the experimental feature to RegionBasedIsolation.
This ensures that the pass is called TransferNonSendable but the experimental
feature is RegionBasedIsolation.
2023-10-26 12:01:44 -07:00
Michael Gottesman
0bad8f9b67 [region-isolation] Rename SendNonSendable.cpp -> TransferNonSendable.cpp. 2023-10-26 12:01:44 -07:00
Holly Borla
0b1e2feaad [Concurrency] Don't allow initializing global actor isolated stored
properties with non-Sendable type from across isolation boundaries.
2023-10-18 20:47:30 -07:00
Michael Gottesman
026f1735b5 [send-non-sendable] Update concurrency tests so that we run them in all concurrency modes as appropriate.
This means that:

1. In test cases where minimal is the default (swift 5 without
-warn-concurrency), I added RUN lines for targeted, complete, and complete +
sns.

2. In test cases where complete is the default (swift 6, -warn-concurrency,
specified complete with -strict-concurrency), I added a send non-sendable run
line.

In each of these cases, I added additional expected-* lines as appropriate so
the tests can compile in each mode successfully.
2023-08-30 13:40:17 -07:00
BJ Homer
bf472c2954 Adjust tests new actor isolation rules in Swift 6.
`HasMainActorWrappedProp` was testing the inference rule that a type
that uses actor-isolated property wrappers its itself isolated to that
same actor. In Swift 6, that inference has been removed, so this test
now verifies that the type is _not_ actor isolated.
2023-02-21 23:44:14 -07:00
Doug Gregor
eef2704c86 Reimplement actor isolation checking for referencing a declaration.
Start collapsing the several implementations of actor isolation checking
into a single place that determines what it means to reference a declaration
from a given context, potentially supplying an instance for an actor. This
is partly cleanup, and partly staging for the implementation of the
Sendable restrictions introduced in SE-0338. The result of this check
falls into one of three categories:

* Reference occurs within the same concurrency domain (actor/task)
* Reference leaves an actor context to a nonisolated context (SE-0338)
* Reference enters the context of the actor, which might require a
combination of implicit async, implicit throws, and a "distributed" check.

Throughout this change I've sought to maintain the existing semantics,
even where I believe they are incorrect. The changes to the test cases
are not semantic changes, but reflect the unification of some
diagnostic paths that changed the diagnostic text but not when or how
those diagnostics are produced. Additionally, SE-0338 has not yet been
implemented, although this refactoring makes it easier to implement
SE-0338.

Use this new actor isolation checking scheme to implement the most
common actor-isolation check, which occurs when accessing a member of
an instance.
2022-04-07 09:07:36 -07:00
Rintaro Ishizaki
20750b7d42 [Tests] Add REQUIRES: asserts to -swift-version 6 tests 2022-02-07 09:38:03 -08:00
Kavon Farvardin
13dd3d9ecf have the inferred isolation for properties change only in Swift 6
This patch delays the removal of redundant isolation for inferred
global-actor isolation to Swift 6 too, since we only warn about it
changing in Swift 5. Otherwise, only isolation that is a byproduct
of inference no longer needs an await, which will probably confuse
people.

This change is with respect to SE-327, which argues that the
non-static stored properties of ordinary structs do not need
global-actor isolation.
2022-02-04 14:43:12 -07:00