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
[Concurrency] Check actor isolation consistency for overrides & subclasses.
Both overriding declarations and subclasses must have the actor
isolation as their overridden declarations or superclasses,
respectively. Enforce this, ensuring that we're also doing the
appropriate substitutions.
func method(){} // expected-note{{only asynchronous methods can be used outside the actor instance}}
35
39
@@ -88,3 +92,55 @@ class C5 {
88
92
c5.method1() // OK: no propagation
89
93
c5.method2() // expected-error{{instance method 'method2()' isolated to global actor 'SomeGlobalActor' can not be referenced from different global actor 'OtherGlobalActor'}}
// expected-error@-1{{instance method 'method1()' must be isolated to the global actor 'SomeGlobalActor' to satisfy corresponding requirement from protocol 'P2'}}
104
+
// expected-error@-2{{instance method 'method1()' must be isolated to the global actor 'OtherGlobalActor' to satisfy corresponding requirement from protocol 'P3'}}
@GenericGlobalActor<T>func method2(){} // expected-note {{overridden declaration is here}}
120
+
@GenericGlobalActor<T>func method3(){} // expected-note {{overridden declaration is here}}
121
+
@GenericGlobalActor<T>func method4(){}
122
+
@GenericGlobalActor<T>func method5(){}
123
+
}
124
+
125
+
actorclass GenericSub<T>:GenericSuper<[T]>{
126
+
overridefunc method(){} // expected-note{{only asynchronous methods can be used outside the actor instance; do you want to add 'async'?}}
127
+
128
+
@GenericGlobalActor<T>overridefunc method2(){} // expected-error{{global actor 'GenericGlobalActor<T>'-isolated instance method 'method2()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
129
+
@actorIndependentoverridefunc method3(){} // expected-error{{actor-independent instance method 'method3()' has different actor isolation from global actor 'GenericGlobalActor<[T]>'-isolated overridden declaration}}
130
+
131
+
@OtherGlobalActorfunc testMethod(){
132
+
method() // expected-error{{instance method 'method()' isolated to global actor 'GenericGlobalActor<[T]>' can not be referenced from different global actor 'OtherGlobalActor'}}
@GenericGlobalActor<U>classSubclass2:Container<[U]>.Superclass{} // expected-error{{global actor 'GenericGlobalActor<U>'-isolated class 'Subclass2' has different actor isolation from global actor 'GenericGlobalActor<[U]>'-isolated superclass 'Superclass'}}
0 commit comments