Skip to content

Commit 1c68d06

Browse files
committed
Update actor isolation tests
Updated the tests for non-global-actor protected deinit. We can't access main-actor synchronous functions, main-actor static properties, but can access non-static main-actor stored properties in the deinit.
1 parent dbeb7ac commit 1c68d06

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/Concurrency/actor_isolation.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ struct GenericGlobalActor<T> {
336336

337337
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
338338
@MainActor func beets() { onions() } // expected-error{{call to global actor 'SomeGlobalActor'-isolated global function 'onions()' in a synchronous main actor-isolated context}}
339+
// expected-note@-1{{calls to global function 'beets()' from outside of its actor context are implicitly asynchronous}}
339340

340341
@available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)
341342
actor Crystal {
@@ -686,7 +687,7 @@ class SomeClassWithInits {
686687
var mutableState: Int = 17
687688
var otherMutableState: Int
688689

689-
static var shared = SomeClassWithInits() // expected-note{{static property declared here}}
690+
static var shared = SomeClassWithInits() // expected-note 2{{static property declared here}}
690691

691692
init() { // expected-note{{calls to initializer 'init()' from outside of its actor context are implicitly asynchronous}}
692693
self.mutableState = 42
@@ -696,7 +697,9 @@ class SomeClassWithInits {
696697
}
697698

698699
deinit {
699-
print(SomeClassWithInits.shared) // okay, we're actor-isolated
700+
print(mutableState) // Okay, we're actor-isolated
701+
print(SomeClassWithInits.shared) // expected-error{{static property 'shared' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
702+
beets() //expected-error{{call to main actor-isolated global function 'beets()' in a synchronous nonisolated context}}
700703
}
701704

702705
func isolated() { }

0 commit comments

Comments
 (0)