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 @@ -2864,13 +2864,18 @@ namespace {
2864
2864
}
2865
2865
}
2866
2866
2867
+ // Does the reference originate from a @preconcurrency context?
2868
+ bool preconcurrencyContext =
2869
+ result.options .contains (ActorReferenceResult::Flags::Preconcurrency);
2870
+
2867
2871
ctx.Diags .diagnose (
2868
2872
loc, diag::actor_isolated_non_self_reference,
2869
2873
decl->getDescriptiveKind (),
2870
2874
decl->getName (),
2871
2875
useKind,
2872
2876
refKind + 1 , refGlobalActor,
2873
- result.isolation );
2877
+ result.isolation )
2878
+ .warnUntilSwiftVersionIf (preconcurrencyContext, 6 );
2874
2879
2875
2880
noteIsolatedActorMember (decl, context);
2876
2881
@@ -5124,6 +5129,10 @@ ActorReferenceResult ActorReferenceResult::forReference(
5124
5129
// to perform.
5125
5130
Options options = None;
5126
5131
5132
+ // Note if the reference originates from a @preconcurrency-isolated context.
5133
+ if (contextIsolation.preconcurrency ())
5134
+ options |= Flags::Preconcurrency;
5135
+
5127
5136
// If the declaration isn't asynchronous, promote to async.
5128
5137
if (!isAsyncDecl (declRef))
5129
5138
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