-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Description
Motivation
swift currently has the (private) @_unavailableFromAsync attribute, which can be used to mark a function as not being available from async contexts.
this attribute can only be used with functions, but not with getters for computed properties.
for example, this program would not compile (regardless of whether the attribute is placed before or after the get or is applied to the variable as a whole):
struct S {
var p: Int {
@_unavailableFromAsync get {
12
}
}
}the specific motivation this is coming from is an API which uses macros to generate get/set accessors for computed static properties which implement a synchronization mechanism, and therefore should not be used from async code.
Proposed solution
it might be worthwhile to consider allowing using this attribute with computed properties as well, especially given the fact that these are essentially just implicit function calls.
Alternatives considered
No response
Additional information
No response