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
_ =text[0] // expected-error{{actor-isolated property 'text' can not be referenced from an '@actorIndependent' context}}
@@ -261,8 +261,8 @@ struct GenericStruct<T> {
261
261
f() // okay
262
262
}
263
263
264
-
// expected-note@+2 {{add '@asyncHandler' to function 'h()' to create an implicit asynchronous context}}
265
-
// expected-note@+1 {{add 'async' to function 'h()' to make it asynchronous}}
264
+
// expected-note@+2 {{add '@asyncHandler' to function 'h()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
265
+
// expected-note@+1 {{add 'async' to function 'h()' to make it asynchronous}} {{none}}
266
266
@GenericGlobalActor<String>func h(){
267
267
f() // expected-error{{'async' in a function that does not support concurrency}}
268
268
_ = f // expected-error{{instance method 'f()' isolated to global actor 'GenericGlobalActor<T>' can not be referenced from different global actor 'GenericGlobalActor<String>'}}
// expected-note@+1 13 {{calls to global function 'syncGlobActorFn()' from outside of its actor context are implicitly asynchronous}}
14
+
@SomeGlobalActorfunc syncGlobActorFn(){}
15
+
@SomeGlobalActorfunc asyncGlobalActFn()async{}
16
+
17
+
actorclass Alex {
18
+
@SomeGlobalActorletconst_memb=20
19
+
@SomeGlobalActorvarmut_memb=30 // expected-note 2 {{mutable state is only available within the actor instance}}
20
+
@SomeGlobalActorfunc method(){} // expected-note 2 {{calls to instance method 'method()' from outside of its actor context are implicitly asynchronous}}
// expected-note@+1 4 {{add '@SomeGlobalActor' to make global function 'referenceGlobalActor()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
31
+
func referenceGlobalActor(){
32
+
leta=Alex()
33
+
// expected-error@+1 {{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
34
+
_ = a.method
35
+
_ = a.const_memb
36
+
_ = a.mut_memb // expected-error{{property 'mut_memb' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
37
+
38
+
_ =a[1] // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
39
+
a[0]=1 // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
40
+
}
41
+
42
+
43
+
// expected-note@+1 {{add '@SomeGlobalActor' to make global function 'referenceGlobalActor2()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
44
+
func referenceGlobalActor2(){
45
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
46
+
letx= syncGlobActorFn
47
+
x()
48
+
}
49
+
50
+
51
+
// expected-note@+2 {{add '@asyncHandler' to function 'referenceAsyncGlobalActor()' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
52
+
// expected-note@+1 {{add 'async' to function 'referenceAsyncGlobalActor()' to make it asynchronous}} {{none}}
53
+
func referenceAsyncGlobalActor(){
54
+
lety= asyncGlobalActFn
55
+
y() // expected-error{{'async' in a function that does not support concurrency}}
56
+
}
57
+
58
+
59
+
// expected-note@+3 {{add '@asyncHandler' to function 'callGlobalActor()' to create an implicit asynchronous context}} {{1-1=@asyncHandler }}
60
+
// expected-note@+2 {{add 'async' to function 'callGlobalActor()' to make it asynchronous}} {{none}}
61
+
// expected-note@+1 {{add '@SomeGlobalActor' to make global function 'callGlobalActor()' part of global actor 'SomeGlobalActor'}} {{1-1=@SomeGlobalActor }}
62
+
func callGlobalActor(){
63
+
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
64
+
}
65
+
66
+
func fromClosure(){
67
+
{()->Voidin
68
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
69
+
letx= syncGlobActorFn
70
+
x()
71
+
}()
72
+
73
+
// expected-error@+2 {{'async' in a function that does not support concurrency}}
74
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
75
+
let _ ={syncGlobActorFn()}()
76
+
}
77
+
78
+
classTaylor{
79
+
init(){ // expected-note {{add 'async' to function 'init()' to make it asynchronous}} {{none}}
80
+
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
81
+
82
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
83
+
_ = syncGlobActorFn
84
+
}
85
+
86
+
deinit{
87
+
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
88
+
89
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
90
+
_ = syncGlobActorFn
91
+
}
92
+
93
+
// expected-note@+3 2 {{add '@SomeGlobalActor' to make instance method 'method1()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
94
+
// expected-note@+2 {{add '@asyncHandler' to function 'method1()' to create an implicit asynchronous context}} {{3-3=@asyncHandler }}
95
+
// expected-note@+1 {{add 'async' to function 'method1()' to make it asynchronous}} {{none}}
96
+
func method1(){
97
+
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
98
+
99
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
100
+
_ = syncGlobActorFn
101
+
}
102
+
103
+
// expected-note@+2 2 {{add '@SomeGlobalActor' to make instance method 'cannotBeHandler()' part of global actor 'SomeGlobalActor'}} {{3-3=@SomeGlobalActor }}
104
+
// expected-note@+1 {{add 'async' to function 'cannotBeHandler()' to make it asynchronous}}
105
+
func cannotBeHandler()->Int{
106
+
syncGlobActorFn() // expected-error {{'async' in a function that does not support concurrency}}
107
+
108
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
109
+
_ = syncGlobActorFn
110
+
return0
111
+
}
112
+
}
113
+
114
+
115
+
func fromAsync()async{
116
+
// expected-error@+1 {{global function 'syncGlobActorFn()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
117
+
letx= syncGlobActorFn
118
+
x()
119
+
120
+
lety= asyncGlobalActFn
121
+
y() // expected-error{{call is 'async' but is not marked with 'await'}}
122
+
123
+
leta=Alex()
124
+
// expected-error@+1 {{instance method 'method()' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
125
+
_ = a.method
126
+
_ = a.const_memb
127
+
_ = a.mut_memb // expected-error{{property 'mut_memb' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
128
+
129
+
_ =a[1] // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
130
+
a[0]=1 // expected-error{{subscript 'subscript(_:)' isolated to global actor 'SomeGlobalActor' can not be referenced from this context}}
0 commit comments