Commit Graph

13 Commits

Author SHA1 Message Date
Anthony Latsis
6512aa1f5a AST: Introduce and use ValueDecl::isAsync 2025-03-25 02:07:03 +00:00
Allan Shortlidge
272b2b43de AST: Accept AvailabilityDomains as diagnostic arguments.
This simplifies the code to emit availabilty diagnostics and ensures that they
display domain names consistently. While updating existing diagnostics, improve
consistency along other dimensions as well.
2025-02-28 09:18:38 -08:00
Allan Shortlidge
4fa8c559da Sema: Fix diagnostics for @available(noasync, swift). 2025-01-28 13:47:42 -08:00
Allan Shortlidge
904518088a Sema: Diagnose @available attibutes that cannot be noasync.
Instead of asserting.
2025-01-26 13:50:56 -08:00
Anthony Latsis
9ae3cf1034 AST: Delete the DeclarationUnavailableFromAsynchronousContext diagnostic group
This group has not shipped yet and was added mainly to support test
coverage for d56b7df8a9. Now that we have
unit tests for this, delete the group, pending discussion.
2025-01-07 20:29:07 +00:00
Dmitrii Galimzianov
d56b7df8a9 Add DiagGroupID to Diagnostic
This change addresses the following issue: when an error is being wrapped in a warning, the diagnostic message will use the wrapper's `DiagGroupID` as the warning's name. However, we want to retain the original error's group for use. For example, in Swift 5, async_unavailable_decl is wrapped in error_in_future_swift_version. When we print a diagnostic of this kind, we want to keep the `DiagGroupID` of `async_unavailable_decl`, not that of `error_in_future_swift_version`.
To achieve this, we add `DiagGroupID` to the `Diagnostic` class. When an active diagnostic is wrapped in DiagnosticEngine, we retain the original `DiagGroupID`.

For illustration purposes, this change also introduces a new group: `DeclarationUnavailableFromAsynchronousContext`.

With this change, we produce errors and warnings of this kind with messages like the following:

```
global function 'fNoAsync' is unavailable from asynchronous contexts [DeclarationUnavailableFromAsynchronousContext]
global function 'fNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode [DeclarationUnavailableFromAsynchronousContext]
```
2024-12-03 20:12:11 +01:00
Jamie
e68c36bca2 [Sema]: improve noasync diagnostics in defer statement bodies
updates noasync diagnostics in TypeCheckAvailability.cpp to diagnose
defer bodies as if they had the same `isAsyncContext()` value as their
nearest non-defer parent scope.

resolves: https://github.com/apple/swift/issues/73614
2024-05-25 09:53:20 -05:00
Holly Borla
9ba481ad53 [Diagnostics] Clarify the wording of error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Evan Wilde
28cd439387 Add missing warnUntilSwift 6
Missed setting a diagnostic as a warning until swift 6, resulting in
noasync functions being emitted as errors in Swift 5.x. This fixes that
so they are only warnings until Swift 6.

Since `@_unavailableFromAsync` is serialized as `@available(*, noasync)`
in the swiftinterface/swiftmodule, this affects functions that are
imported from other modules as well.
2022-06-28 09:48:44 -07:00
Evan Wilde
504a52add4 Use SwiftStdlib availability
Was missing some platforms causing certain builds to fail.
Adding SwiftStdlib availability annotation, which should cover all of
them.
2022-03-23 10:29:51 -07:00
Evan Wilde
900383708b Fix remaining test issues
Needed to add availability information for macOS, iOS, and watchOS to
avoid emitting unintended errors on the `async` keyword.
2022-03-22 15:12:51 -07:00
Evan Wilde
249c2a11d0 Typecheck noasync attr
This patch adds validation to ensure that the noasync attribute is only
applied to useful declarations.
Specifically, the `noasync` attribute cannot be applied to `deinit`
declarations, asynchronous functions, or asynchronous properties.
2022-03-22 15:12:51 -07:00
Evan Wilde
aa51bdf17a Add noasync availability kind to available attr
This patch adds the `noasync` availability kind to `@available`. The
spelling is `@available(*, noasync)`.
2022-03-22 15:12:51 -07:00