[Concurrency] Allow #isolation to have a more specific contextual type.

This commit is contained in:
Holly Borla
2024-02-16 14:22:53 -08:00
parent ea7d07714f
commit ddf2fc44f4
4 changed files with 43 additions and 1 deletions

View File

@@ -25,6 +25,7 @@
#include "swift/AST/ExistentialLayout.h"
#include "swift/AST/GenericEnvironment.h"
#include "swift/AST/Initializer.h"
#include "swift/AST/MacroDefinition.h"
#include "swift/AST/ParameterList.h"
#include "swift/AST/ProtocolConformance.h"
#include "swift/AST/TypeCheckRequests.h"
@@ -3964,6 +3965,16 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
// Record a fix here
(void)recordFix(MacroMissingPound::create(*this, macro, locator));
}
// The default type of the #isolation builtin macro is `(any Actor)?`
if (macro->getBuiltinKind() == BuiltinMacroKind::IsolationMacro) {
auto *fnType = openedType->getAs<FunctionType>();
auto actor = getASTContext().getProtocol(KnownProtocolKind::Actor);
addConstraint(
ConstraintKind::Defaultable, fnType->getResult(),
OptionalType::get(actor->getDeclaredExistentialType()),
locator);
}
}
}