File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -2919,13 +2919,18 @@ namespace {
2919
2919
}
2920
2920
}
2921
2921
2922
+ // Does the reference originate from a @preconcurrency context?
2923
+ bool preconcurrencyContext =
2924
+ result.options .contains (ActorReferenceResult::Flags::Preconcurrency);
2925
+
2922
2926
ctx.Diags .diagnose (
2923
2927
loc, diag::actor_isolated_non_self_reference,
2924
2928
decl->getDescriptiveKind (),
2925
2929
decl->getName (),
2926
2930
useKind,
2927
2931
refKind + 1 , refGlobalActor,
2928
- result.isolation );
2932
+ result.isolation )
2933
+ .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
2929
2934
2930
2935
noteIsolatedActorMember (decl, context);
2931
2936
@@ -5179,6 +5184,10 @@ ActorReferenceResult ActorReferenceResult::forReference(
5179
5184
// to perform.
5180
5185
Options options = None;
5181
5186
5187
+ // Note if the reference originates from a @preconcurrency-isolated context.
5188
+ if (contextIsolation.preconcurrency ())
5189
+ options |= Flags::Preconcurrency;
5190
+
5182
5191
// If the declaration isn't asynchronous, promote to async.
5183
5192
if (!isAsyncDecl (declRef))
5184
5193
options |= Flags::AsyncPromotion;
Original file line number Diff line number Diff line change @@ -210,6 +210,9 @@ struct ActorReferenceResult {
210
210
// / The declaration is being accessed from outside the actor and
211
211
// / potentially from a different node, so it must be marked 'distributed'.
212
212
Distributed = 1 << 2 ,
213
+
214
+ // / The declaration is being accessed from a @preconcurrency context.
215
+ Preconcurrency = 1 << 3 ,
213
216
};
214
217
215
218
using Options = OptionSet<Flags>;
Original file line number Diff line number Diff line change @@ -381,3 +381,17 @@ public struct SomeWrapper<T: AuditedNonSendable> {
381
381
}
382
382
383
383
extension SomeWrapper : Sendable where T: Sendable { }
384
+
385
+
386
+ // rdar://96830159
387
+ @MainActor class SendableCompletionHandler {
388
+ var isolatedThing : [ String ] = [ ]
389
+ // expected-note@-1 {{property declared here}}
390
+
391
+ func makeCall( slowServer: SlowServer ) {
392
+ slowServer. doSomethingSlow ( " churn butter " ) { ( _ : Int ) in
393
+ let _ = self . isolatedThing
394
+ // expected-warning@-1 {{main actor-isolated property 'isolatedThing' can not be referenced from a Sendable closure; this is an error in Swift 6}}
395
+ }
396
+ }
397
+ }
You can’t perform that action at this time.
0 commit comments