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) {
538538 //
539539 auto *func = fri->getReferencedFunction ();
540540 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 ())
548549 .withUnsafeNonIsolated (true );
550+ }
549551 }
550552 }
551553 }
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ protocol ProvidesStaticValue {
3030@MainActor func transferToMainIndirectConsuming< T> ( _ t: consuming T ) async { }
3131@MainActor func transferToMainDirectConsuming( _ t: consuming NonSendableKlass ) async { }
3232
33+ func useInOut< T> ( _ t: inout T ) { }
34+
3335actor CustomActorInstance { }
3436
3537@globalActor
@@ -349,13 +351,28 @@ func testAccessStaticGlobals() async {
349351nonisolated ( unsafe) let globalNonIsolatedUnsafeLetObject = NonSendableKlass ( )
350352nonisolated ( unsafe) var globalNonIsolatedUnsafeVarObject = NonSendableKlass ( )
351353
352- func testAccessGlobals ( ) async {
354+ func testPassGlobalToMainActorIsolatedFunction ( ) async {
353355 await transferToMainDirect ( globalNonIsolatedUnsafeLetObject)
354356 await transferToMainIndirect ( globalNonIsolatedUnsafeLetObject)
355357 await transferToMainDirect ( globalNonIsolatedUnsafeVarObject)
356358 await transferToMainIndirect ( globalNonIsolatedUnsafeVarObject)
357359}
358360
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+
359376///////////////////////
360377// MARK: Field Tests //
361378///////////////////////
You can’t perform that action at this time.
0 commit comments