swift
1b8f5628 - Adjust the referenced function type for @_unsafeSendable and @_unsafeMainActor.

Commit
4 years ago
Adjust the referenced function type for @_unsafeSendable and @_unsafeMainActor. When referencing a function that contains parameters with the hidden `@_unsafeSendable` or `@_unsafeMainActor` attributes, adjust the function type to make the types of those parameters `@Sendable` or `@MainActor`, respectively, based on both the context the expression: * `@Sendable` will be applied when we are in a context with strict concurrency checking. * `@MainActor` will be applied when we are in a context with strict concurrency checking *or* the function is being directly applied so that an argument is provided in the immediate expression. The second part of the rule of `@MainActor` reflects the fact that making the parameter `@MainActor` doesn't break existing code (because there is a conversion to add a global actor to a function value), but it does enable such code to synchronously use a `@MainActor`-qualified API. The main effect of this change is that, in a strict concurrency context, the type of referencing an unapplied function involving `@_unsafeSendable` or `@_unsafeMainActor` in a strict context will make those parameters `@Sendable` or `@MainActor`, which ensures that these constraints properly work with non-closure arguments. The former solution only applied to closure literals, which left some holes in Sendable checking. Fixes rdar://77753021.
Author
Committer
Parents
Loading