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
import OtherActors // expected-warning{{add '@preconcurrency' to suppress 'Sendable'-related warnings from module 'OtherActors'}}{{1-1=@preconcurrency }}
12
14
13
15
letimmutableGlobal:String="hello"
14
16
15
-
// expected-warning@+4 {{var 'mutableGlobal' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in the Swift 6 language mode}}
16
-
// expected-note@+3 {{convert 'mutableGlobal' to a 'let' constant to make the shared state immutable}}
17
-
// expected-note@+2 {{restrict 'mutableGlobal' to the main actor if it will only be accessed from the main thread}}
18
-
// expected-note@+1 {{unsafely mark 'mutableGlobal' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
@@ -12,12 +16,7 @@ let rs = GlobalCounter() // expected-warning {{let 'rs' is not concurrency-safe
12
16
// expected-note@-1 {{restrict 'rs' to the main actor if it will only be accessed from the main thread}}
13
17
// expected-note@-2 {{unsafely mark 'rs' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
14
18
15
-
16
-
varglobalInt=17 // expected-warning {{var 'globalInt' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in the Swift 6 language mode}}
17
-
// expected-note@-1 {{restrict 'globalInt' to the main actor if it will only be accessed from the main thread}}
18
-
// expected-note@-2 2{{var declared here}}
19
-
// expected-note@-3 {{unsafely mark 'globalInt' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
20
-
// expected-note@-4 {{convert 'globalInt' to a 'let' constant to make the shared state immutable}}
19
+
import GlobalVariables
21
20
22
21
classMyError:Error{ // expected-warning{{non-final class 'MyError' cannot conform to 'Sendable'; use '@unchecked Sendable'}}
23
22
varstorage=0 // expected-warning{{stored property 'storage' of 'Sendable'-conforming class 'MyError' is mutable}}
Copy file name to clipboardExpand all lines: test/Concurrency/flow_isolation.swift
+3-6Lines changed: 3 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -521,9 +521,8 @@ struct CardboardBox<T> {
521
521
@available(SwiftStdlib 5.1,*)
522
522
varglobalVar:EscapeArtist? // expected-warning {{var 'globalVar' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in the Swift 6 language mode}}
523
523
// expected-note@-1 {{restrict 'globalVar' to the main actor if it will only be accessed from the main thread}}
524
-
// expected-note@-2 2 {{var declared here}}
525
-
// expected-note@-3 {{unsafely mark 'globalVar' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
526
-
// expected-note@-4 {{convert 'globalVar' to a 'let' constant to make the shared state immutable}}
524
+
// expected-note@-2 {{unsafely mark 'globalVar' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
525
+
// expected-note@-3 {{convert 'globalVar' to a 'let' constant to make the shared state immutable}}
527
526
528
527
@available(SwiftStdlib 5.1,*)
529
528
actorEscapeArtist{
@@ -532,11 +531,9 @@ actor EscapeArtist {
532
531
init(attempt1:Bool){
533
532
self.x =0
534
533
535
-
// expected-note@+2 {{after making a copy of 'self', only non-isolated properties of 'self' can be accessed from this init}}
536
-
// expected-warning@+1 {{reference to var 'globalVar' is not concurrency-safe because it involves shared mutable state}}
534
+
// expected-note@+1 {{after making a copy of 'self', only non-isolated properties of 'self' can be accessed from this init}}
537
535
globalVar =self
538
536
539
-
// expected-warning@+1 {{reference to var 'globalVar' is not concurrency-safe because it involves shared mutable state}}
540
537
Task{await globalVar!.isolatedMethod()}
541
538
542
539
ifself.x ==0{ // expected-warning {{cannot access property 'x' here in non-isolated initializer; this is an error in the Swift 6 language mode}}
// expected-complete-warning@+5 {{var 'global' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in the Swift 6 language mode}}
5
-
// expected-complete-note@+4 {{restrict 'global' to the main actor if it will only be accessed from the main thread}}{{1-1=@MainActor }}
// expected-complete-warning@+4 {{var 'global' is not concurrency-safe because it is non-isolated global shared mutable state; this is an error in the Swift 6 language mode}}
5
+
// expected-complete-note@+3 {{restrict 'global' to the main actor if it will only be accessed from the main thread}}{{1-1=@MainActor }}
7
6
// expected-complete-note@+2 {{unsafely mark 'global' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}{{1-1=nonisolated(unsafe) }}
8
7
// expected-complete-note@+1 {{convert 'global' to a 'let' constant to make the shared state immutable}}{{1-4=let}}
9
8
varglobal=10
10
9
11
-
// expected-complete-warning@+1 {{reference to var 'global' is not concurrency-safe because it involves shared mutable state; this is an error in the Swift 6 language mode}}
// expected-note@-3{{unsafely mark 'mutable' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
65
-
// expected-note@-4{{restrict 'mutable' to the main actor if it will only be accessed from the main thread}}
63
+
// expected-note@-2{{unsafely mark 'mutable' as concurrency-safe if all accesses are protected by an external synchronization mechanism}}
64
+
// expected-note@-3{{restrict 'mutable' to the main actor if it will only be accessed from the main thread}}
66
65
staticvarcomputedProperty:Int{0} // computed property that, though static, has no storage so is not a global
67
66
@TestWrapperstaticvarwrapped:Int // expected-error{{static property 'wrapped' is not concurrency-safe because it is non-isolated global shared mutable state}}
68
67
// expected-note@-1{{convert 'wrapped' to a 'let' constant to make the shared state immutable}}{{23-26=let}}
@@ -79,7 +78,7 @@ public actor TestPublicActor {
79
78
func f(){
80
79
print(TestStatics.immutableExplicitSendable)
81
80
print(TestStatics.immutableInferredSendable)
82
-
print(TestStatics.mutable) // expected-error{{reference to static property 'mutable' is not concurrency-safe because it involves shared mutable state}}
81
+
print(TestStatics.mutable)
83
82
print(Globals.actorInteger) // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from global actor 'TestGlobalActor'}}
0 commit comments