mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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:
@@ -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()) {
|
||||
|
||||
Reference in New Issue
Block a user