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
+ other.balance() // expected-error{{call is 'async' but is not marked with 'await'}}
101
+
}
102
+
103
+
func breakAccounts(other:BankAccount)async{
104
+
_ = other.deposit( // expected-error{{call is 'async' but is not marked with 'await'}}
105
+
other.withdraw( // expected-error{{call is 'async' but is not marked with 'await'}}
106
+
self.deposit(
107
+
other.withdraw( // expected-error{{call is 'async' but is not marked with 'await'}}
108
+
other.balance())))) // expected-error{{call is 'async' but is not marked with 'await'}}
109
+
}
110
+
}
111
+
112
+
func anotherAsyncFunc()async{
113
+
leta=BankAccount(initialDeposit:34)
114
+
letb=BankAccount(initialDeposit:35)
115
+
116
+
_ = a.deposit(1) // expected-error{{call is 'async' but is not marked with 'await'}}
117
+
_ = b.balance() // expected-error{{call is 'async' but is not marked with 'await'}}
118
+
119
+
_ = b.balance // expected-error {{actor-isolated instance method 'balance()' can only be referenced inside the actor}}
120
+
121
+
a.owner ="cat" // expected-error{{actor-isolated property 'owner' can only be referenced inside the actor}}
122
+
_ = b.owner // expected-error{{actor-isolated property 'owner' can only be referenced inside the actor}}
123
+
124
+
}
125
+
126
+
// expected-note@+2 {{add 'async' to function 'regularFunc()' to make it asynchronous}}
127
+
// expected-note@+1 {{add '@asyncHandler' to function 'regularFunc()' to create an implicit asynchronous context}}
128
+
func regularFunc(){
129
+
leta=BankAccount(initialDeposit:34)
130
+
131
+
_ = a.deposit //expected-error{{actor-isolated instance method 'deposit' can only be referenced inside the actor}}
132
+
133
+
_ = a.deposit(1) // expected-error{{'async' in a function that does not support concurrency}}
134
+
}
135
+
136
+
137
+
actorclass TestActor {}
138
+
139
+
@globalActor
140
+
structBananaActor{
141
+
staticvarshared:TestActor{TestActor()}
142
+
}
143
+
144
+
@globalActor
145
+
structOrangeActor{
146
+
staticvarshared:TestActor{TestActor()}
147
+
}
148
+
149
+
func blender(_ peeler :()->Void){
150
+
peeler()
151
+
}
152
+
153
+
@BananaActorfunc wisk(_ something :Any){} // expected-note 4 {{only asynchronous methods can be used outside the actor instance}}
154
+
155
+
@BananaActorfunc peelBanana(){} // expected-note 2 {{only asynchronous methods can be used outside the actor instance}}
156
+
157
+
@OrangeActorfunc makeSmoothie()async{
158
+
awaitwisk({})
159
+
awaitwisk(1)
160
+
await(peelBanana)()
161
+
await(((((peelBanana)))))()
162
+
await(((wisk)))((wisk)((wisk)(1)))
163
+
164
+
blender((peelBanana)) // expected-error {{global function 'peelBanana()' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
165
+
awaitwisk(peelBanana) // expected-error {{global function 'peelBanana()' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
166
+
167
+
awaitwisk(wisk) // expected-error {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
168
+
await(((wisk)))(((wisk))) // expected-error {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
169
+
170
+
// expected-warning@+2 {{no calls to 'async' functions occur within 'await' expression}}
171
+
// expected-error@+1 {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
172
+
await{wisk}()(1)
173
+
174
+
// expected-warning@+2 {{no calls to 'async' functions occur within 'await' expression}}
175
+
// expected-error@+1 {{global function 'wisk' isolated to global actor 'BananaActor' can not be referenced from different global actor 'OrangeActor'}}
0 commit comments