Treat references to enum cases with associated values as @Sendable functions

When `InferSendableFromCaptures`, make sure to treat references to enum
cases that have associated values as `@Sendable` functions.
This commit is contained in:
Doug Gregor
2024-06-12 14:54:09 -07:00
parent 9c868f8454
commit c65264738b
2 changed files with 23 additions and 1 deletions

View File

@@ -1747,8 +1747,16 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
});
if (Context.LangOpts.hasFeature(Feature::InferSendableFromCaptures)) {
DeclContext *DC = nullptr;
if (auto *FD = dyn_cast<AbstractFunctionDecl>(decl)) {
auto *DC = FD->getDeclContext();
DC = FD->getDeclContext();
} else if (auto EED = dyn_cast<EnumElementDecl>(decl)) {
if (EED->hasAssociatedValues()) {
DC = EED->getDeclContext();
}
}
if (DC) {
// All global functions should be @Sendable
if (DC->isModuleScopeContext()) {
if (!adjustedTy->getExtInfo().isSendable()) {