Commit Graph

5 Commits

Author SHA1 Message Date
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
110839e801 Add cross-module test
Verify importing noasync across modules works correctly.
2022-03-22 15:12:51 -07:00
Evan Wilde
aa9085a3d8 Handle attr parse failures
Adding nice error messages for when things go wrong.
2021-12-08 09:39:24 -08:00
Evan Wilde
3a13721eae Add optional message to unavailablefromasync
Adding the ability to add an optional message to the unavailable from
async attribute. This can be used to indicate other possible API to use,
or help explain why it's unavailable.
2021-12-08 09:39:24 -08:00
Evan Wilde
694fad4aef Adding unavailableFromAsync tests
This patch adds a bunch of tests to verify the behaviour of the
@_unavailableFromAsync attribute.

The attribute is only allowed on functions, so we verify that an error
is emitted when it is applied to structs, extensions, classes, and
actors. The attribute may be applied to constructors to disallow
construction in an async context, but cannot be applied to destructors
since a destructor must be callable from anywhere. Additionally, the
attribute cannot be applied to asynchronous functions since an async
function _must_ be called from an async context.

Specific checks include
 - Errors are emitted in an async context (global function, e.g.)
 - Errors are emitted when the async context is nested in a sync context
 - Errors are not emitted from a sync context nested in an async context

This patch also includes verification that the attribute is propagated
across module boundaries and is be imported from ObjC functions.

Lastly, this patch adds the IDE completion testing to verify that the
attribute is considered.
2021-11-30 14:20:21 -08:00