You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test/Concurrency/actor_isolation.swift
+18-3Lines changed: 18 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -787,12 +787,12 @@ class SomeClassWithInits {
787
787
func hasDetached(){
788
788
Task.detached{
789
789
// okay
790
-
awaitself.isolated() // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
791
-
self.isolated() // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
790
+
awaitself.isolated()
791
+
self.isolated()
792
792
// expected-error@-1{{expression is 'async' but is not marked with 'await'}}{{7-7=await }}
793
793
// expected-note@-2{{calls to instance method 'isolated()' from outside of its actor context are implicitly asynchronous}}
794
794
795
-
print(awaitself.mutableState) // expected-warning{{cannot use parameter 'self' with a non-sendable type 'SomeClassWithInits' from concurrently-executed code}}
795
+
print(awaitself.mutableState)
796
796
}
797
797
}
798
798
}
@@ -940,3 +940,18 @@ actor Counter {
940
940
return counter
941
941
}
942
942
}
943
+
944
+
/// Superclass checks for global actor-qualified class types.
945
+
classC2{}
946
+
947
+
@SomeGlobalActor
948
+
classC3:C2{} // expected-error{{global actor 'SomeGlobalActor'-isolated class 'C3' has different actor isolation from nonisolated superclass 'C2'}}
949
+
950
+
@GenericGlobalActor<U>
951
+
classGenericSuper<U>{}
952
+
953
+
@GenericGlobalActor<[T]>
954
+
classGenericSub1<T>:GenericSuper<[T]>{}
955
+
956
+
@GenericGlobalActor<T>
957
+
classGenericSub2<T>:GenericSuper<[T]>{} // expected-error{{global actor 'GenericGlobalActor<T>'-isolated class 'GenericSub2' has different actor isolation from global actor 'GenericGlobalActor<U>'-isolated superclass 'GenericSuper'}}
// expected-error@-1{{global actor 'GenericGlobalActor<U>'-isolated class 'Subclass2' has different actor isolation from global actor 'GenericGlobalActor<T>'-isolated superclass 'Superclass'}}
201
202
202
203
// Ensure that substitutions work properly when inheriting.
203
204
classSubclass3<V>:Container<(U,V)>.Superclass2{
@@ -218,7 +219,7 @@ class SuperclassWithGlobalActors {
218
219
func j(){}
219
220
}
220
221
221
-
@GenericGlobalActor<String>
222
+
@GenericGlobalActor<String> // expected-error@+1{{global actor 'GenericGlobalActor<String>'-isolated class 'SubclassWithGlobalActors' has different actor isolation from nonisolated superclass 'SuperclassWithGlobalActors'}}
0 commit comments