Commit Graph

24 Commits

Author SHA1 Message Date
Pavel Yaskevich
dd95c60c70 [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
(cherry picked from commit 7a6ba8e8c58c58b3438f31fec06102d02bae81a5)
2025-05-22 23:52:02 -07:00
Daniel Rodríguez Troitiño
5abb1ea6ac [test] Remove some REQUIRES: for features not longer used in those files
While doing #76740 I iteratively was adding new `REQUIRES:` as new
usages of the features were found, but I did not realize that at the
same time other people might be removing some of those usages. The tests
in this commit had some `REQUIRES:` line for a previous
`-enable-experimental/upcoming-feature`, but they not longer use those
features, so the `REQUIRES:` were effectively disabling the tests (at
least in the case of `KeyPathWithStaticMembers`. In other cases they
might still had executed).
2024-11-04 20:53:07 -08:00
Daniel Rodríguez Troitiño
ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07: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
Holly Borla
7de7eafd22 [Concurrency] Don't walk into sending closures when computing the
required isolation of a default value expression.
2024-10-11 16:04:58 -07:00
Holly Borla
bd9a84597b [Concurrency] Downgrade the isolated default argument error to a warning when the
isolation of the argument expression is `@preconcurrency`.
2024-10-01 12:19:38 -04:00
Holly Borla
c4f6793dbf [Concurrency] Consider isolated key-path components when computing the required
isolation of a stored property initializer.

This allows isolated key-path components to be used in stored property
initializers when the stored property itself is isolated to the same
global actor.
2024-07-08 19:20:59 -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
a11dc3c60e [Concurrency] Don't call getAllMembers() while inferring actor isolation for
implicit initializers.

This messes with conformance synthesis for `RawRepresentable` and friends because
it invokes conformance synthesis too early.
2024-01-20 10:42:55 -08:00
Holly Borla
cc1fd1ce8f [Concurrency] Don't skip pattern bindings with multiple vars when inferring the
isolation of implicit initializers.
2024-01-20 10:03:51 -08:00
Holly Borla
20829faa43 [Concurrency] Handle cases where a property initializer is subsumed by another
property for IsolatedDefaultValues.

For property wrappers and init accesors, skip property initializers that are
subsumed, e.g. by an init accessor or a backing property wrapper initializer,
and always consider the subsuming initializer to determine whether compiler
synthesized initializers should have `nonisolated` applied.

This change also lessens the source break of SE-0411 by still emitting
member initializers in implicit constructors when the initializer violates
actor isolation to preserve the behavior of existing code when concurrency
diagnostics are downgraded to warnings in Swift 5 mode.
2024-01-19 18:12:25 -08:00
Holly Borla
b99995c2b2 [Concurrency] Downgrade isolated_default_argument_context to a warning until
Swift 6 for stored properties.
2024-01-16 10:47:52 -08:00
Holly Borla
0e71623386 [SE-0411] Promote IsolatedDefaultValues from an experimental feature to an
upcoming feature.
2024-01-10 14:54:24 -08:00
Holly Borla
d6fce014a0 [Concurrency] When isolated default values are enabled, synthesized initializers
should be nonisolated if all initialized properties are Sendable with nonisolated
default values.
2023-11-17 16:19:14 -05:00
Holly Borla
e9750bc4e5 [Concurrency] Diagnose default values whose isolation differs from the corresponding
stored property.
2023-11-16 23:56:08 -05: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
49d6399a88 [Concurrency] Allow isolated default arguments to be used from across isolation
boundaries.
2023-10-24 22:54:22 -07:00
Holly Borla
5a81c00b3e [Concurrency] Rename IsolatedDefaultArguments to IsolatedDefaultValues. 2023-10-06 16:59:41 -07:00
Holly Borla
67e3326048 [Concurrency] Remove swift::computeRequiredIsolation and change all callers to go
through the DefaultInitializerIsolation request.
2023-10-04 15:14:06 -07:00
Holly Borla
7f119474ac [Concurrency] Allow default initializer expressions for stored instance
properties to require actor isolation.

Member initializer expressions are only used in a constructor with
matching actor isolation. If the isolation prohibits the member
initializer from being evaluated synchronously (or propagating required
isolation through closure bodies), then the default value cannot be used
and the member must be explicitly initialized in the constructor.

Member initializer expressions are also used as default arguments for the
memberwise initializer, and the same rules for default argument isolation
apply.
2023-10-04 13:12:11 -07:00
Holly Borla
88b2332ba0 [Concurrency] Handle nested decl contexts while computing the required isolation
for a default argument, and improve diagnostics for conflicting isolation.
2023-10-04 13:12:11 -07:00
Holly Borla
95a7107872 [Concurrency] Allow default arguments to require actor isolation.
Type checking a default argument expression will compute the required
actor isolation for evaluating that argument value synchronously. Actor
isolation checking is deferred to the caller; it is an error to use a
default argument from across isolation domains.

Currently gated behind -enable-experimental-feature IsolatedDefaultArguments.
2023-10-04 13:12:11 -07:00