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
@MainActorvarx=useFooInADefer() // expected-warning {{expression requiring global actor 'MainActor' cannot appear in default-value expression of property 'x'; this is an error in Swift 6}}
590
+
@MainActorvarx=useFooInADefer()
591
591
@MainActorvary={()->Boolin
592
-
varz= statefulThingy // expected-warning {{expression requiring global actor 'MainActor' cannot appear in default-value expression of property 'y'; this is an error in Swift 6}}
592
+
varz= statefulThingy
593
593
return z
594
594
}()
595
595
}
@@ -601,7 +601,7 @@ class Butter {
601
601
nonisolatedletb= statefulThingy // expected-error {{var 'statefulThingy' isolated to global actor 'MainActor' can not be referenced from a non-isolated synchronous context}}
602
602
603
603
varc:Int={
604
-
returngetGlobal7() // expected-warning {{expression requiring global actor 'SomeGlobalActor' cannot appear in default-value expression of property 'c'; this is an error in Swift 6}}
Copy file name to clipboardExpand all lines: test/Concurrency/property_initializers_swift6.swift
+12-8Lines changed: 12 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -3,17 +3,21 @@
3
3
4
4
// REQUIRES: asserts
5
5
6
-
@MainActor
7
-
func mainActorFn()->Int{return0} // expected-note 2 {{calls to global function 'mainActorFn()' from outside of its actor context are implicitly asynchronous}}
6
+
@globalActor
7
+
actorGlobalActor{
8
+
staticletshared=GlobalActor()
9
+
}
10
+
11
+
@GlobalActor
12
+
func globalActorFn()->Int{return0} // expected-note {{calls to global function 'globalActorFn()' from outside of its actor context are implicitly asynchronous}}
8
13
9
-
@MainActor
14
+
@GlobalActor
10
15
classC{
11
-
varx:Int=mainActorFn() // expected-error {{call to main actor-isolated global function 'mainActorFn()' in a synchronous nonisolated context}}
16
+
varx:Int=globalActorFn()
12
17
13
-
lazy vary:Int=mainActorFn()
18
+
lazy vary:Int=globalActorFn()
14
19
15
-
staticvarz:Int=mainActorFn()
20
+
staticvarz:Int=globalActorFn()
16
21
}
17
22
18
-
@MainActor
19
-
varx:Int=mainActorFn() // expected-error {{call to main actor-isolated global function 'mainActorFn()' in a synchronous nonisolated context}}
23
+
varx:Int=globalActorFn() // expected-error {{call to global actor 'GlobalActor'-isolated global function 'globalActorFn()' in a synchronous nonisolated context}}
0 commit comments