File tree Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Expand file tree Collapse file tree 2 files changed +27
-8
lines changed Original file line number Diff line number Diff line change @@ -538,14 +538,16 @@ SILIsolationInfo SILIsolationInfo::get(SILInstruction *inst) {
538
538
//
539
539
auto *func = fri->getReferencedFunction ();
540
540
auto funcType = func->getLoweredFunctionType ();
541
- auto selfParam = funcType->getSelfInstanceType (
542
- fri->getModule (), func->getTypeExpansionContext ());
543
- if (auto *nomDecl = selfParam->getNominalOrBoundGenericNominal ()) {
544
- auto isolation = swift::getActorIsolation (nomDecl);
545
- if (isolation.isGlobalActor ()) {
546
- return SILIsolationInfo::getGlobalActorIsolated (
547
- fri, isolation.getGlobalActor ())
541
+ if (funcType->hasSelfParam ()) {
542
+ auto selfParam = funcType->getSelfInstanceType (
543
+ fri->getModule (), func->getTypeExpansionContext ());
544
+ if (auto *nomDecl = selfParam->getNominalOrBoundGenericNominal ()) {
545
+ auto isolation = swift::getActorIsolation (nomDecl);
546
+ if (isolation.isGlobalActor ()) {
547
+ return SILIsolationInfo::getGlobalActorIsolated (
548
+ fri, isolation.getGlobalActor ())
548
549
.withUnsafeNonIsolated (true );
550
+ }
549
551
}
550
552
}
551
553
}
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ protocol ProvidesStaticValue {
30
30
@MainActor func transferToMainIndirectConsuming< T> ( _ t: consuming T ) async { }
31
31
@MainActor func transferToMainDirectConsuming( _ t: consuming NonSendableKlass ) async { }
32
32
33
+ func useInOut< T> ( _ t: inout T ) { }
34
+
33
35
actor CustomActorInstance { }
34
36
35
37
@globalActor
@@ -349,13 +351,28 @@ func testAccessStaticGlobals() async {
349
351
nonisolated ( unsafe) let globalNonIsolatedUnsafeLetObject = NonSendableKlass ( )
350
352
nonisolated ( unsafe) var globalNonIsolatedUnsafeVarObject = NonSendableKlass ( )
351
353
352
- func testAccessGlobals ( ) async {
354
+ func testPassGlobalToMainActorIsolatedFunction ( ) async {
353
355
await transferToMainDirect ( globalNonIsolatedUnsafeLetObject)
354
356
await transferToMainIndirect ( globalNonIsolatedUnsafeLetObject)
355
357
await transferToMainDirect ( globalNonIsolatedUnsafeVarObject)
356
358
await transferToMainIndirect ( globalNonIsolatedUnsafeVarObject)
357
359
}
358
360
361
+ // We use this to force the modify in testPassGlobalToModify
362
+ nonisolated ( unsafe)
363
+ var computedGlobalNonIsolatedUnsafeVarObject : NonSendableKlass {
364
+ _read {
365
+ yield globalNonIsolatedUnsafeVarObject
366
+ }
367
+ _modify {
368
+ yield & globalNonIsolatedUnsafeVarObject
369
+ }
370
+ }
371
+
372
+ func testPassGlobalToModify( ) async {
373
+ useInOut ( & computedGlobalNonIsolatedUnsafeVarObject)
374
+ }
375
+
359
376
///////////////////////
360
377
// MARK: Field Tests //
361
378
///////////////////////
You can’t perform that action at this time.
0 commit comments