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
staticletmember=Bar() // expected-complete-warning {{static property 'member' is not concurrency-safe because non-'Sendable' type 'Bar' may have shared mutable state; this is an error in the Swift 6 language mode}}
3
-
// expected-complete-note@-1 {{annotate 'member' with '@MainActor' if property should only be accessed from the main actor}}
3
+
// expected-complete-note@-1 {{add '@MainActor' to make static property 'member' part of global actor 'MainActor'}}
4
4
// expected-complete-note@-2{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
Copy file name to clipboardExpand all lines: test/Concurrency/concurrency_warnings.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@ class GlobalCounter { // expected-note{{class 'GlobalCounter' does not conform t
13
13
14
14
letrs=GlobalCounter() // expected-warning {{let 'rs' is not concurrency-safe because non-'Sendable' type 'GlobalCounter' may have shared mutable state; this is an error in the Swift 6 language mode}}
15
15
// expected-note@-1 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
16
-
// expected-note@-2 {{annotate 'rs' with '@MainActor' if property should only be accessed from the main actor}}
16
+
// expected-note@-2 {{add '@MainActor' to make let 'rs' part of global actor 'MainActor'}}
varconcurrentFuncVar:(@Sendable(NotConcurrent)->Void)?=nil // expected-warning{{var 'concurrentFuncVar' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode}}
298
-
// expected-note@-1 {{annotate 'concurrentFuncVar' with '@MainActor' if property should only be accessed from the main actor}}
298
+
// expected-note@-1 {{add '@MainActor' to make var 'concurrentFuncVar' part of global actor 'MainActor'}}
299
299
// expected-note@-2 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
300
300
// expected-note@-3 {{convert 'concurrentFuncVar' to a 'let' constant to make 'Sendable' shared state immutable}}
Copy file name to clipboardExpand all lines: test/Concurrency/flow_isolation.swift
+1-1
Original file line number
Diff line number
Diff line change
@@ -520,7 +520,7 @@ struct CardboardBox<T> {
520
520
521
521
@available(SwiftStdlib 5.1,*)
522
522
varglobalVar:EscapeArtist? // expected-warning {{var 'globalVar' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode}}
523
-
// expected-note@-1 {{annotate 'globalVar' with '@MainActor' if property should only be accessed from the main actor}}
523
+
// expected-note@-1 {{add '@MainActor' to make var 'globalVar' part of global actor 'MainActor'}}
524
524
// expected-note@-2 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
525
525
// expected-note@-3 {{convert 'globalVar' to a 'let' constant to make 'Sendable' shared state immutable}}
// expected-complete-warning@+4 {{var 'global' is not concurrency-safe because it is nonisolated global shared mutable state; this is an error in the Swift 6 language mode}}
5
-
// expected-complete-note@+3 {{annotate 'global' with '@MainActor' if property should only be accessed from the main actor}}{{1-1=@MainActor }}
5
+
// expected-complete-note@+3 {{add '@MainActor' to make var 'global' part of global actor 'MainActor'}}{{1-1=@MainActor }}
6
6
// expected-complete-note@+2 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}{{1-1=nonisolated(unsafe) }}
7
7
// expected-complete-note@+1 {{convert 'global' to a 'let' constant to make 'Sendable' shared state immutable}}{{1-4=let}}
Copy file name to clipboardExpand all lines: test/Concurrency/global_variables.swift
+5-5
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ actor TestGlobalActor {
15
15
varmutableIsolatedGlobal=1
16
16
17
17
varmutableNonisolatedGlobal=1 // expected-error{{var 'mutableNonisolatedGlobal' is not concurrency-safe because it is nonisolated global shared mutable state}}
18
-
// expected-note@-1{{annotate 'mutableNonisolatedGlobal' with '@MainActor' if property should only be accessed from the main actor}}{{1-1=@MainActor }}
18
+
// expected-note@-1{{add '@MainActor' to make var 'mutableNonisolatedGlobal' part of global actor 'MainActor'}}{{1-1=@MainActor }}
19
19
// expected-note@-2{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}{{1-1=nonisolated(unsafe) }}
20
20
// expected-note@-3{{convert 'mutableNonisolatedGlobal' to a 'let' constant to make 'Sendable' shared state immutable}}{{1-4=let}}
21
21
@@ -48,25 +48,25 @@ actor TestActor {
48
48
structTestStatics{
49
49
staticletimmutableExplicitSendable=TestSendable()
50
50
staticletimmutableNonsendable=TestNonsendable() // expected-error{{static property 'immutableNonsendable' is not concurrency-safe because non-'Sendable' type 'TestNonsendable' may have shared mutable state}}
51
-
// expected-note@-1 {{annotate 'immutableNonsendable' with '@MainActor' if property should only be accessed from the main actor}}
51
+
// expected-note@-1 {{add '@MainActor' to make static property 'immutableNonsendable' part of global actor 'MainActor'}}
52
52
// expected-note@-2 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
staticnonisolatedletimmutableNonisolated=TestNonsendable() // expected-error{{static property 'immutableNonisolated' is not concurrency-safe because non-'Sendable' type 'TestNonsendable' may have shared mutable state}}
55
55
// expected-note@-1 {{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
56
56
// expected-error@-2 {{'nonisolated' can not be applied to variable with non-'Sendable' type 'TestNonsendable'}}
57
-
// expected-note@-3{{annotate 'immutableNonisolated' with '@MainActor' if property should only be accessed from the main actor}}
57
+
// expected-note@-3{{add '@MainActor' to make static property 'immutableNonisolated' part of global actor 'MainActor'}}
// expected-warning@-1 {{'nonisolated(unsafe)' is unnecessary for a constant with 'Sendable' type 'TestSendable', consider removing it}} {{10-30=}}
60
60
staticletimmutableInferredSendable=0
61
61
staticvarmutable=0 // expected-error{{static property 'mutable' is not concurrency-safe because it is nonisolated global shared mutable state}}
62
62
// expected-note@-1{{convert 'mutable' to a 'let' constant to make 'Sendable' shared state immutable}}
63
63
// expected-note@-2{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
64
-
// expected-note@-3{{annotate 'mutable' with '@MainActor' if property should only be accessed from the main actor}}
64
+
// expected-note@-3{{add '@MainActor' to make static property 'mutable' part of global actor 'MainActor'}}
65
65
staticvarcomputedProperty:Int{0} // computed property that, though static, has no storage so is not a global
66
66
@TestWrapperstaticvarwrapped:Int // expected-error{{static property 'wrapped' is not concurrency-safe because it is nonisolated global shared mutable state}}
67
67
// expected-note@-1{{convert 'wrapped' to a 'let' constant to make 'Sendable' shared state immutable}}{{23-26=let}}
68
68
// expected-note@-2{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}{{16-16=nonisolated(unsafe) }}
69
-
// expected-note@-3{{annotate 'wrapped' with '@MainActor' if property should only be accessed from the main actor}}{{3-3=@MainActor }}
69
+
// expected-note@-3{{add '@MainActor' to make static property 'wrapped' part of global actor 'MainActor'}}{{3-3=@MainActor }}
Copy file name to clipboardExpand all lines: test/Concurrency/predates_concurrency_import.swift
+2-2
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ let nonStrictGlobal = NonStrictClass() // no warning
44
44
45
45
letstrictGlobal=StrictStruct() // expected-warning{{let 'strictGlobal' is not concurrency-safe because non-'Sendable' type 'StrictStruct' may have shared mutable state}}
46
46
// expected-note@-1{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
47
-
// expected-note@-2{{annotate 'strictGlobal' with '@MainActor' if property should only be accessed from the main actor}}
47
+
// expected-note@-2{{add '@MainActor' to make let 'strictGlobal' part of global actor 'MainActor'}}
48
48
49
49
extensionNonStrictClass{
50
50
@Sendablefunc f(){}
@@ -62,7 +62,7 @@ struct HasStatics {
62
62
// expected-warning@-1{{'nonisolated' can not be applied to variable with non-'Sendable' type 'StrictStruct'}}
63
63
// expected-warning@-2{{static property 'ss' is not concurrency-safe because non-'Sendable' type 'StrictStruct' may have shared mutable state}}
64
64
// expected-note@-3{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
65
-
// expected-note@-4{{annotate 'ss' with '@MainActor' if property should only be accessed from the main actor}}
65
+
// expected-note@-4{{add '@MainActor' to make static property 'ss' part of global actor 'MainActor'}}
letstrictGlobal=StrictStruct() // expected-warning{{let 'strictGlobal' is not concurrency-safe because non-'Sendable' type 'StrictStruct' may have shared mutable state}}
21
-
// expected-note@-1{{annotate 'strictGlobal' with '@MainActor' if property should only be accessed from the main actor}}
21
+
// expected-note@-1{{add '@MainActor' to make let 'strictGlobal' part of global actor 'MainActor'}}
22
22
// expected-note@-2{{disable concurrency-safety checks if accesses are protected by an external synchronization mechanism}}
0 commit comments