@@ -49,7 +49,10 @@ actor Convenient {
49
49
guard val > 0 else { throw BogusError . blah }
50
50
self . x = 10
51
51
say ( msg: " hello? " ) // expected-error {{this use of actor 'self' can only appear in an async initializer}}
52
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
53
+
52
54
Task { self } // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
55
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
53
56
}
54
57
55
58
init ( asyncThrowyDesignated val: Int ) async throws {
@@ -95,15 +98,26 @@ actor MyActor {
95
98
96
99
func helloWorld( ) { }
97
100
101
+ convenience init ( ci1 c: Bool ) {
102
+ self . init ( i1: c)
103
+ Task { self }
104
+ callMethod ( self )
105
+ }
106
+
98
107
init ( i1 c: Bool ) {
99
108
self . x = 0
100
109
_ = self . x
101
110
self . y = self . x
102
111
103
112
Task { self } // expected-error{{actor 'self' can only be captured by a closure from an async initializer}}
113
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
104
114
105
115
self . helloWorld ( ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
116
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
117
+
106
118
callMethod ( self ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
119
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
120
+
107
121
passInout ( & self . x) // expected-error{{actor 'self' can only be passed 'inout' from an async initializer}}
108
122
109
123
self . x = self . y
@@ -115,9 +129,13 @@ actor MyActor {
115
129
_ = self . hax
116
130
117
131
_ = computedProp // expected-error{{this use of actor 'self' can only appear in an async initializer}}
132
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
133
+
118
134
computedProp = 1 // expected-error{{this use of actor 'self' can only appear in an async initializer}}
135
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
119
136
120
137
Task { // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
138
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
121
139
_ = await self . hax
122
140
await self . helloWorld ( )
123
141
}
@@ -129,9 +147,14 @@ actor MyActor {
129
147
self . y = self . x
130
148
131
149
Task { self } // expected-error{{actor 'self' can only be captured by a closure from an async initializer}}
150
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
132
151
133
152
self . helloWorld ( ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
153
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
154
+
134
155
callMethod ( self ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
156
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
157
+
135
158
passInout ( & self . x) // expected-error{{actor 'self' can only be passed 'inout' from an async initializer}}
136
159
137
160
self . x = self . y
@@ -140,9 +163,13 @@ actor MyActor {
140
163
_ = self . hax
141
164
142
165
_ = computedProp // expected-error{{this use of actor 'self' can only appear in an async initializer}}
166
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
167
+
143
168
computedProp = 1 // expected-error{{this use of actor 'self' can only appear in an async initializer}}
169
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
144
170
145
171
Task { // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
172
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
146
173
_ = await self . hax
147
174
await self . helloWorld ( )
148
175
}
@@ -154,9 +181,14 @@ actor MyActor {
154
181
self . y = self . x
155
182
156
183
Task { self } // expected-error{{actor 'self' can only be captured by a closure from an async initializer}}
184
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
157
185
158
186
self . helloWorld ( ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
187
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
188
+
159
189
callMethod ( self ) // expected-error{{this use of actor 'self' can only appear in an async initializer}}
190
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
191
+
160
192
passInout ( & self . x) // expected-error{{actor 'self' can only be passed 'inout' from an async initializer}}
161
193
162
194
self . x = self . y
@@ -165,9 +197,13 @@ actor MyActor {
165
197
_ = self . hax
166
198
167
199
_ = computedProp // expected-error{{this use of actor 'self' can only appear in an async initializer}}
200
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
201
+
168
202
computedProp = 1 // expected-error{{this use of actor 'self' can only appear in an async initializer}}
203
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
169
204
170
205
Task { // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
206
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
171
207
_ = await self . hax
172
208
await self . helloWorld ( )
173
209
}
@@ -179,9 +215,14 @@ actor MyActor {
179
215
self . y = self . x
180
216
181
217
Task { self } // expected-error{{actor 'self' cannot be captured by a closure from a global-actor isolated initializer}}
218
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
182
219
183
220
self . helloWorld ( ) // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
221
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
222
+
184
223
callMethod ( self ) // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
224
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
225
+
185
226
passInout ( & self . x) // expected-error{{actor 'self' cannot be passed 'inout' from a global-actor isolated initializer}}
186
227
187
228
self . x = self . y
@@ -190,9 +231,13 @@ actor MyActor {
190
231
_ = self . hax
191
232
192
233
_ = computedProp // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
234
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
235
+
193
236
computedProp = 1 // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
237
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
194
238
195
239
Task { // expected-error {{actor 'self' cannot be captured by a closure from a global-actor isolated initializer}}
240
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
196
241
_ = await self . hax
197
242
await self . helloWorld ( )
198
243
}
@@ -228,9 +273,14 @@ actor MyActor {
228
273
self . y = self . x
229
274
230
275
Task { self } // expected-error{{actor 'self' cannot be captured by a closure from a global-actor isolated initializer}}
276
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
231
277
232
278
self . helloWorld ( ) // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
279
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
280
+
233
281
callMethod ( self ) // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
282
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
283
+
234
284
passInout ( & self . x) // expected-error{{actor 'self' cannot be passed 'inout' from a global-actor isolated initializer}}
235
285
236
286
self . x = self . y
@@ -239,9 +289,13 @@ actor MyActor {
239
289
_ = self . hax
240
290
241
291
_ = computedProp // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
292
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
293
+
242
294
computedProp = 1 // expected-error{{this use of actor 'self' cannot appear in a global-actor isolated initializer}}
295
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
243
296
244
297
Task { // expected-error {{actor 'self' cannot be captured by a closure from a global-actor isolated initializer}}
298
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
245
299
_ = await self . hax
246
300
await self . helloWorld ( )
247
301
}
@@ -257,6 +311,7 @@ actor X {
257
311
init ( v1 start: Int ) {
258
312
self . counter = start
259
313
Task { await self . setCounter ( start + 1 ) } // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
314
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
260
315
261
316
if self . counter != start {
262
317
fatalError ( " where's my protection? " )
@@ -319,8 +374,10 @@ actor EscapeArtist {
319
374
let unchainedSelf = self
320
375
321
376
unchainedSelf. nonisolated ( ) // expected-error {{this use of actor 'self' can only appear in an async initializer}}
377
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
322
378
323
379
let _ = { unchainedSelf. nonisolated ( ) } // expected-error {{actor 'self' can only be captured by a closure from an async initializer}}
380
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
324
381
}
325
382
326
383
init ( attempt5: Bool ) {
@@ -336,6 +393,7 @@ actor EscapeArtist {
336
393
self . nonisolated ( )
337
394
}
338
395
fn ( ) // expected-error {{this use of actor 'self' can only appear in an async initializer}}
396
+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
339
397
}
340
398
341
399
func isolatedMethod( ) { x += 1 }
0 commit comments