File tree Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Expand file tree Collapse file tree 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -1710,8 +1710,16 @@ FunctionType *ConstraintSystem::adjustFunctionTypeForConcurrency(
1710
1710
});
1711
1711
1712
1712
if (Context.LangOpts .hasFeature (Feature::InferSendableFromCaptures)) {
1713
+ DeclContext *DC = nullptr ;
1713
1714
if (auto *FD = dyn_cast<AbstractFunctionDecl>(decl)) {
1714
- auto *DC = FD->getDeclContext ();
1715
+ DC = FD->getDeclContext ();
1716
+ } else if (auto EED = dyn_cast<EnumElementDecl>(decl)) {
1717
+ if (EED->hasAssociatedValues ()) {
1718
+ DC = EED->getDeclContext ();
1719
+ }
1720
+ }
1721
+
1722
+ if (DC) {
1715
1723
// All global functions should be @Sendable
1716
1724
if (DC->isModuleScopeContext ()) {
1717
1725
if (!adjustedTy->getExtInfo ().isSendable ()) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ struct InferredSendableS: P {
42
42
43
43
enum InferredSendableE : P {
44
44
case a, b
45
+ case c( Int )
45
46
46
47
func f( ) { }
47
48
}
@@ -60,6 +61,13 @@ struct GenericS<T> : P {
60
61
func g( ) async { }
61
62
}
62
63
64
+ enum GenericE < T> {
65
+ case a
66
+ case b( T )
67
+ }
68
+
69
+ extension GenericE : Sendable where T: Sendable { }
70
+
63
71
class NonSendable {
64
72
func f( ) { }
65
73
}
265
273
true ? nil : c // Ok
266
274
}
267
275
}
276
+
277
+ func acceptSendableFunc< T, U> ( _: @Sendable ( T ) -> U ) { }
278
+
279
+ acceptSendableFunc ( InferredSendableE . c)
280
+ acceptSendableFunc ( GenericE< Int> . b)
281
+ acceptSendableFunc ( GenericE< NonSendable> . b)
You can’t perform that action at this time.
0 commit comments