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
@SomeGlobalActorfunc syncGlobalActorFunc(){} // expected-note 3{{only asynchronous methods can be used outside the actor instance; do you want to add 'async'?}}
@GenericGlobalActor<T>func f(){} // expected-note{{only asynchronous methods can be used outside the actor instance; do you want to add 'async'?}}
249
+
250
+
@GenericGlobalActor<T>func g(){
251
+
f() // okay
252
+
}
253
+
254
+
@GenericGlobalActor<String>func h(){
255
+
f() // expected-error{{instance method 'f()' isolated to global actor 'GenericGlobalActor<T>' can not be referenced from different global actor 'GenericGlobalActor<String>'}}
Copy file name to clipboardExpand all lines: test/attr/global_actor.swift
+10Lines changed: 10 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,11 @@ struct GA1 {
15
15
staticletshared=SomeActor()
16
16
}
17
17
18
+
@globalActor
19
+
structGenericGlobalActor<T>{
20
+
staticvarshared:SomeActor{SomeActor()}
21
+
}
22
+
18
23
// Ill-formed global actors.
19
24
@globalActor
20
25
openclassGA2{ // expected-error{{global actor 'GA2' requires a static property 'shared' that produces an actor instance}}{{17-17=\n public static let shared = <#actor instance#>}}
@@ -82,6 +87,11 @@ class SomeClass {
82
87
83
88
@GA1@OtherGlobalActorfunc twoGlobalActors(){} // expected-error{{declaration can not have multiple global actor attributes ('OtherGlobalActor' and 'GA1')}}
84
89
90
+
structContainer{
91
+
// FIXME: Diagnostic could be improved to show the generic arguments.
92
+
@GenericGlobalActor<Int>@GenericGlobalActor<String>func twoGenericGlobalActors(){} // expected-error{{declaration can not have multiple global actor attributes ('GenericGlobalActor' and 'GenericGlobalActor')}}
0 commit comments