Commit Graph

2 Commits

Author SHA1 Message Date
Evan Wilde
110839e801 Add cross-module test
Verify importing noasync across modules works correctly.
2022-03-22 15:12:51 -07: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