Skip to content

Commit 7afb399

Browse files
authored
Merge pull request swiftlang#35129 from etcwilde/ewilde/global-actor-sync-function-call-test-case
[Concurrency] NFC: Adding top-level sync call with inout global actor state
2 parents 32b7e36 + 5bca066 commit 7afb399

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

test/Concurrency/global_actor_from_ordinary_context.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,11 @@ func fromAsync() async {
128128

129129
_ = a[1] // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
130130
a[0] = 1 // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
131-
}
131+
}
132+
133+
// expected-note@+1{{mutable state is only available within the actor instance}}
134+
@SomeGlobalActor var value: Int = 42
135+
136+
func topLevelSyncFunction(_ number: inout Int) { }
137+
// expected-error@+1{{var 'value' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
138+
topLevelSyncFunction(&value)

0 commit comments

Comments
 (0)