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
classC1{} // expected-note{{class 'C1' does not conform to the 'Sendable' protocol}}
13
9
classC2{}
14
10
@@ -19,85 +15,15 @@ protocol TestProtocol {
19
15
associatedtypeValue:Sendable
20
16
}
21
17
22
-
structTest1:TestProtocol{ // expected-error{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}}
18
+
structTest1:TestProtocol{ // expected-warning{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}}
23
19
typealiasValue=C1
24
20
}
25
21
26
-
structTest2:TestProtocol{ // expected-error{{conformance of 'C2' to 'Sendable' is unavailable}}
22
+
structTest2:TestProtocol{ // expected-warning{{conformance of 'C2' to 'Sendable' is unavailable}}
27
23
// expected-note@-1{{in associated type 'Self.Value' (inferred as 'C2')}}
28
24
typealiasValue=C2
29
25
}
30
26
31
-
@globalActor
32
-
actorTestGlobalActor{
33
-
staticvarshared=TestGlobalActor()
34
-
}
35
-
36
-
@TestGlobalActor
37
-
varmutableIsolatedGlobal=1
38
-
39
-
varmutableNonisolatedGlobal=1 // expected-error{{var 'mutableNonisolatedGlobal' is not concurrency-safe because it is non-isolated global shared mutable state}}
40
-
// expected-note@-1{{isolate 'mutableNonisolatedGlobal' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
staticletimmutableNonsendable=TestNonsendable() // expected-error{{static property 'immutableNonsendable' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor}}
staticnonisolatedletimmutableNonisolated=TestNonsendable() // expected-error{{static property 'immutableNonisolated' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor}}
67
-
staticletimmutableInferredSendable=0
68
-
staticvarmutable=0 // expected-error{{static property 'mutable' is not concurrency-safe because it is non-isolated global shared mutable state}}
69
-
// expected-note@-1{{isolate 'mutable' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
staticvarcomputedProperty:Int{0} // computed property that, though static, has no storage so is not a global
72
-
@TestWrapperstaticvarwrapped:Int // expected-error{{static property 'wrapped' is not concurrency-safe because it is non-isolated global shared mutable state}}
73
-
// expected-note@-1{{isolate 'wrapped' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
74
-
}
75
-
76
-
@TestGlobalActor
77
-
func f(){
78
-
print(TestStatics.immutableExplicitSendable)
79
-
print(TestStatics.immutableInferredSendable)
80
-
print(TestStatics.mutable) // expected-error{{reference to static property 'mutable' is not concurrency-safe because it involves shared mutable state}}
81
-
print(Globals.actorInteger) // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from global actor 'TestGlobalActor'}}
82
-
}
83
-
84
-
func testLocalNonisolatedUnsafe()async{
85
-
nonisolated(unsafe)varvalue=1
86
-
lettask=Task{
87
-
value =2
88
-
return value
89
-
}
90
-
print(await task.value)
91
-
}
92
-
93
-
func testCGlobals(){ // expected-note{{add '@MainActor' to make global function 'testCGlobals()' part of global actor 'MainActor'}}
94
-
let _ =Globals.integerConstant
95
-
let _ =Globals.integerMutable // expected-warning{{reference to static property 'integerMutable' is not concurrency-safe because it involves shared mutable state}}
96
-
let _ =Globals.nonisolatedUnsafeIntegerConstant
97
-
let _ =Globals.nonisolatedUnsafeIntegerMutable
98
-
let _ =Globals.actorInteger // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from a non-isolated context}}
varmutableNonisolatedGlobal=1 // expected-error{{var 'mutableNonisolatedGlobal' is not concurrency-safe because it is non-isolated global shared mutable state}}
19
+
// expected-note@-1{{isolate 'mutableNonisolatedGlobal' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
staticletimmutableNonsendable=TestNonsendable() // expected-error{{static property 'immutableNonsendable' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor}}
staticnonisolatedletimmutableNonisolated=TestNonsendable() // expected-error{{static property 'immutableNonisolated' is not concurrency-safe because it is not either conforming to 'Sendable' or isolated to a global actor}}
46
+
staticletimmutableInferredSendable=0
47
+
staticvarmutable=0 // expected-error{{static property 'mutable' is not concurrency-safe because it is non-isolated global shared mutable state}}
48
+
// expected-note@-1{{isolate 'mutable' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
staticvarcomputedProperty:Int{0} // computed property that, though static, has no storage so is not a global
51
+
@TestWrapperstaticvarwrapped:Int // expected-error{{static property 'wrapped' is not concurrency-safe because it is non-isolated global shared mutable state}}
52
+
// expected-note@-1{{isolate 'wrapped' to a global actor, or convert it to a 'let' constant and conform it to 'Sendable'}}
53
+
}
54
+
55
+
@TestGlobalActor
56
+
func f(){
57
+
print(TestStatics.immutableExplicitSendable)
58
+
print(TestStatics.immutableInferredSendable)
59
+
print(TestStatics.mutable) // expected-error{{reference to static property 'mutable' is not concurrency-safe because it involves shared mutable state}}
60
+
print(Globals.actorInteger) // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from global actor 'TestGlobalActor'}}
61
+
}
62
+
63
+
func testLocalNonisolatedUnsafe()async{
64
+
nonisolated(unsafe)varvalue=1
65
+
lettask=Task{
66
+
value =2
67
+
return value
68
+
}
69
+
print(await task.value)
70
+
}
71
+
72
+
func testImportedGlobals(){ // expected-note{{add '@MainActor' to make global function 'testImportedGlobals()' part of global actor 'MainActor'}}
73
+
let _ =Globals.integerConstant
74
+
let _ =Globals.integerMutable // expected-warning{{reference to static property 'integerMutable' is not concurrency-safe because it involves shared mutable state}}
75
+
let _ =Globals.nonisolatedUnsafeIntegerConstant
76
+
let _ =Globals.nonisolatedUnsafeIntegerMutable
77
+
let _ =Globals.actorInteger // expected-error{{main actor-isolated static property 'actorInteger' can not be referenced from a non-isolated context}}
0 commit comments