Commit Graph

24 Commits

Author SHA1 Message Date
Anthony Latsis
2cd90bdd69 AST: Quote attributes more consistently in DiagnosticsSema.def 2025-04-22 18:23:36 +01: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
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
9fb198ff71 Sema: Do not diagnose preconcurrency redundancy in implied conformances 2025-01-30 06:35:43 +00:00
Anthony Latsis
e626887dcc Sema: Improve requirement indicator note for actor_isolated_witness
`x declared here` is not helpful and clear enough, especially when there
are other notes attached. Swap it for a new note that says
`requirement x declared here`.
2025-01-14 14:52:41 +00:00
Anthony Latsis
f85eb97337 ConformanceChecker: Make actor_isolated_witness call out the protocol 2025-01-14 14:49:22 +00: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
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
Pavel Yaskevich
414295df96 [AST] @preconcurrency conformance applies to implied conformances as well
A `@preconcurrency` conformance to an inherited protocol should imply
`@preconcurrency` on its parents as well. For example:

```swift
protocol Parent {
  func a()
}

protocol Child: Parent {
  func b()
}

@MainActor
class Test: @preconcurrency Child {
  func a() {
  }

  func b() {
  }
}
```

`Test` conformance to `Parent` implied by its conformance to `Child`
should carry `@preconcurrency` and inject dynamic actor isolation checks
to witness of `a()`.

Resolves: https://github.com/apple/swift/issues/74294
Resolves: rdar://129599097
2024-06-11 15:52:41 -07:00
Doug Gregor
1aaba1f285 Don't check sendability of witnesses for @preconcurrency conformances
When a witness is part of a `@preconcurrency` conformance, suppress
Sendable checking for that witness because we assume that the caller is
correctly invoking this witness from within the right isolation
domain. This property is dynamically checked.

Fixes https://github.com/apple/swift/issues/74057.
2024-06-05 22:44:44 -07:00
Doug Gregor
5a0e70a2bc Update diagnostic text to address code review feedback 2024-05-20 22:06:40 -07:00
Doug Gregor
640042f396 Suggest @preconcurrency on conformances it could help
When diagnosing a case where an actor-isolated witness cannot satisfy
a non-isolated requirement, also suggest that the conformance could be
annotated with `@preconcurrency`.
2024-05-20 22:06:40 -07:00
Doug Gregor
e9220b48d8 Add a Fix-It to the warning about unnecessary @preconcurrency conformance
When we diagnose an unnecessary `@preconcurrency` on a conformance,
also provide a Fix-It to remove the `@preconcurrency`.
2024-05-19 17:03:08 -07:00
Pavel Yaskevich
03e9d4258e [Frontend] NFC: Promote DynamicActorIsolation to an upcoming feature flag 2024-04-14 21:28:13 -07:00
Pavel Yaskevich
db7959668e [Frontend] NFC: Rename PreconcurrencyConformances to DynamicActorIsolation 2024-02-01 13:28:25 -08:00
Pavel Yaskevich
c3a0822260 [Tests] NFC: Disable availability checking in @preconcurrency conformances tests 2024-01-16 16:21:06 -08:00
Pavel Yaskevich
1caafee3cf [Sema] Diagnose places where @preconcurrency attribute on conformance has no effect 2024-01-16 11:51:49 -08:00
Pavel Yaskevich
13f83598ea [Sema] @preconcurrency conformances have no effect for protocols that adopted concurrency
Don't treat isolated or explicitly `nonisolated` requirements as
preconcurrency because in that case we consider protocol as
concurrency adopter.
2024-01-16 11:51:49 -08:00
Pavel Yaskevich
451308422b [Sema] Suppress actor isolation checking for @preconcurrency conformances
Suppress warnings/errors when actor isolated synchroneous witness
is matched against `@preconcurrency` conformance requirement.

Witness thunk assumes isolation of the witness but instead of a
hop to its executor it would emit a runtime check to make sure
that its always called from the expected context.
2024-01-16 11:51:49 -08:00
Pavel Yaskevich
4943e146bd [Frontend] Add experimental flag for @preconcurrency conformances feature 2024-01-16 10:31:01 -08:00