Allow conversions from actor-bound sync function type to unbound async function type.

For `async` function types, an actor constraint can be enforced by the callee by hopping executors,
unlike with `sync` functions, so doesn't need to influence the outward type of the function.

rdar://76248452
This commit is contained in:
Joe Groff
2021-05-03 09:17:17 -07:00
parent 283abc0f35
commit 92f56e7ec8
19 changed files with 225 additions and 17 deletions

View File

@@ -2114,8 +2114,8 @@ ConstraintSystem::matchFunctionTypes(FunctionType *func1, FunctionType *func2,
auto result = matchTypes(func1->getGlobalActor(), func2->getGlobalActor(), ConstraintKind::Equal, subflags, locator);
if (result == SolutionKind::Error)
return getTypeMatchFailure(locator);
} else if (func1->getGlobalActor()) {
// Cannot remove a global actor.
} else if (func1->getGlobalActor() && !func2->isAsync()) {
// Cannot remove a global actor from a synchronous function.
if (!shouldAttemptFixes())
return getTypeMatchFailure(locator);