File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -425,3 +425,28 @@ actor Ahmad {
425425 // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
426426 }
427427}
428+
429+ @available ( SwiftStdlib 5 . 5 , * )
430+ actor Rain {
431+ var x : Int = 0
432+ func f( ) { }
433+
434+ init ( ) {
435+ defer { self . f ( ) } // expected-warning {{this use of actor 'self' can only appear in an async initializer}}
436+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
437+
438+ defer { _ = self . x } // expected-warning {{this use of actor 'self' can only appear in an async initializer}}
439+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
440+
441+ defer { Task { await self . f ( ) } } // expected-warning {{this use of actor 'self' can only appear in an async initializer}}
442+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
443+ }
444+
445+ init ( ) async {
446+ defer { self . f ( ) }
447+
448+ defer { _ = self . x }
449+
450+ defer { Task { await self . f ( ) } }
451+ }
452+ }
Original file line number Diff line number Diff line change @@ -423,3 +423,28 @@ actor Ahmad {
423423 // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
424424 }
425425}
426+
427+ @available ( SwiftStdlib 5 . 5 , * )
428+ actor Rain {
429+ var x : Int = 0
430+ func f( ) { }
431+
432+ init ( ) {
433+ defer { self . f ( ) } // expected-error {{this use of actor 'self' can only appear in an async initializer}}
434+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
435+
436+ defer { _ = self . x } // expected-error {{this use of actor 'self' can only appear in an async initializer}}
437+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
438+
439+ defer { Task { await self . f ( ) } } // expected-error {{this use of actor 'self' can only appear in an async initializer}}
440+ // expected-note@-1 {{convenience initializers allow non-isolated use of 'self' once initialized}}
441+ }
442+
443+ init ( ) async {
444+ defer { self . f ( ) }
445+
446+ defer { _ = self . x }
447+
448+ defer { Task { await self . f ( ) } }
449+ }
450+ }
You can’t perform that action at this time.
0 commit comments