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
Copy file name to clipboardExpand all lines: test/Concurrency/async_initializer.swift
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -103,18 +103,19 @@ enum E {
103
103
}
104
104
105
105
structSomeStruct{
106
-
@MainActorinit(asyncMainActor:Int)async{}
106
+
@MainActorinit(asyncMainActor:Int)async{} // expected-note{{calls to initializer 'init(asyncMainActor:)' from outside of its actor context are implicitly asynchronous}}
107
107
@MainActorinit(mainActor:Int){} // expected-note {{calls to initializer 'init(mainActor:)' from outside of its actor context are implicitly asynchronous}}
// expected-note@+2 {{add '@MainActor' to make global function 'globActorTest1()' part of global actor 'MainActor'}}
112
+
// expected-note@+2 2{{add '@MainActor' to make global function 'globActorTest1()' part of global actor 'MainActor'}}
113
113
// expected-note@+1 2 {{add 'async' to function 'globActorTest1()' to make it asynchronous}}
114
114
func globActorTest1(){
115
115
_ =SomeStruct(asyncMainActor:0) // expected-error {{'async' call in a function that does not support concurrency}}
116
+
// expected-error@-1{{call to main actor-isolated initializer 'init(asyncMainActor:)' in a synchronous nonisolated context}}
116
117
117
-
_ =SomeStruct(mainActor:0) // expected-error {{initializer 'init(mainActor:)' isolated to global actor 'MainActor' can not be referenced from this synchronous context}}
118
+
_ =SomeStruct(mainActor:0) // expected-error {{call to main actor-isolated initializer 'init(mainActor:)' in a synchronous nonisolated context}}
118
119
119
120
_ =SomeStruct(asyncMainActorUnsafe:0) // expected-error {{'async' call in a function that does not support concurrency}}
120
121
@@ -162,4 +163,4 @@ protocol Spicy: Plain {
162
163
// expected-error@+2 {{cannot override non-async initializer with async initializer}}
163
164
// expected-error@+1 {{initializer does not override a designated initializer from its parent protocol}}
0 commit comments