File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -3186,6 +3186,20 @@ namespace {
3186
3186
/* setThrows*/ !explicitlyThrowing,
3187
3187
/* isDistributedThunk=*/ true );
3188
3188
}
3189
+
3190
+ // In compiler versions <=5.10, the compiler did not diagnose cases
3191
+ // where a non-isolated distributed actor value was passed to a VarDecl
3192
+ // with a function type type that has an isolated distributed actor
3193
+ // parameter, e.g. `(isolated DA) -> Void`. Stage in the error as a
3194
+ // warning until Swift 6.
3195
+ if (var->getTypeInContext ()->getAs <FunctionType>()) {
3196
+ ctx.Diags .diagnose (declLoc,
3197
+ diag::distributed_actor_isolated_non_self_reference,
3198
+ decl)
3199
+ .warnUntilSwiftVersion (6 );
3200
+ noteIsolatedActorMember (decl, context);
3201
+ return std::nullopt;
3202
+ }
3189
3203
}
3190
3204
3191
3205
// FIXME: Subscript?
Original file line number Diff line number Diff line change @@ -50,3 +50,16 @@ distributed actor DA {
50
50
}
51
51
52
52
}
53
+
54
+ func invalidIsolatedCall< DA: DistributedActor > (
55
+ to actor : DA ,
56
+ queue: AsyncStream < @Sendable ( isolated DA) async -> Void >
57
+ ) {
58
+ Task {
59
+ // expected-note@+1 {{let declared here}}
60
+ for await closure in queue {
61
+ // expected-warning@+1 {{distributed actor-isolated let 'closure' can not be accessed from a non-isolated context; this is an error in Swift 6}}
62
+ await closure ( actor )
63
+ }
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments