File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2806,7 +2806,9 @@ ConstraintSystem::getTypeOfMemberReference(
2806
2806
FunctionType::ExtInfo info;
2807
2807
2808
2808
if (Context.LangOpts .hasFeature (Feature::InferSendableFromCaptures)) {
2809
- if (isPartialApplication (locator) && baseOpenedTy->isSendableType ()) {
2809
+ if (isPartialApplication (locator) &&
2810
+ (resolvedBaseTy->is <AnyMetatypeType>() ||
2811
+ baseOpenedTy->isSendableType ())) {
2810
2812
// Add @Sendable to functions without conditional conformances
2811
2813
functionType =
2812
2814
functionType
Original file line number Diff line number Diff line change @@ -46,3 +46,19 @@ extension S: Sendable where T: Sendable {
46
46
47
47
@available ( SwiftStdlib 5 . 1 , * )
48
48
@MainActor @Sendable func globalActorFuncAsync( ) async { }
49
+
50
+ func test_initializer_ref( ) {
51
+ func test< T> ( _: @Sendable ( T , T ) -> Array < T > ) {
52
+ }
53
+
54
+ // Type of `initRef` should be @Sendable but due to implicitly injected autoclosure it isn't
55
+ let initRef = Array . init as ( Int , Int ) -> Array < Int >
56
+
57
+ // FIXME: incorrect non-Sendable diagnostic is produced due to `autoclosure` wrapping `Array.init`
58
+ test ( initRef)
59
+ // expected-warning@-1 {{onverting non-sendable function value to '@Sendable (Int, Int) -> Array<Int>' may introduce data races}}
60
+
61
+ // FIXME: Same here
62
+ test ( Array . init as ( Int , Int ) -> Array < Int > )
63
+ // expected-warning@-1 {{onverting non-sendable function value to '@Sendable (Int, Int) -> Array<Int>' may introduce data races}}
64
+ }
You can’t perform that action at this time.
0 commit comments