Skip to content

Commit 3450cf6

Browse files
committed
[region-isolation] Change a test to use the name "CustomActor" instead of "GlobalActor" for its custom global actor.
Just makes it easier to read. NFC.
1 parent b19081d commit 3450cf6

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

test/Concurrency/transfernonsendable_global_actor.swift

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
class NonSendableKlass {}
1212
final class SendableKlass : Sendable {}
1313

14-
actor GlobalActorInstance {}
14+
actor CustomActorInstance {}
1515

1616
@globalActor
17-
struct GlobalActor {
18-
static let shared = GlobalActorInstance()
17+
struct CustomActor {
18+
static let shared = CustomActorInstance()
1919
}
2020

2121
func transferToNonIsolated<T>(_ t: T) async {}
2222
@MainActor func transferToMainActor<T>(_ t: T) async {}
23-
@GlobalActor func transferToGlobalActor<T>(_ t: T) async {}
23+
@CustomActor func transferToCustomActor<T>(_ t: T) async {}
2424
func useValue<T>(_ t: T) {}
2525

2626
var booleanFlag: Bool { false }
@@ -42,59 +42,59 @@ private class NonSendableLinkedListNode<T> { // expected-complete-note 3{{}}
4242
init() { next = nil }
4343
}
4444

45-
@GlobalActor private var firstList = NonSendableLinkedList<Int>()
46-
@GlobalActor private var secondList = NonSendableLinkedList<Int>()
45+
@CustomActor private var firstList = NonSendableLinkedList<Int>()
46+
@CustomActor private var secondList = NonSendableLinkedList<Int>()
4747

48-
@GlobalActor func useGlobalActor1() async {
48+
@CustomActor func useCustomActor1() async {
4949
let x = firstList
5050

5151
await transferToMainActor(x) // expected-tns-warning {{transferring 'x' may cause a race}}
52-
// expected-tns-note @-1 {{transferring global actor 'GlobalActor'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and global actor 'GlobalActor'-isolated uses}}
52+
// expected-tns-note @-1 {{transferring global actor 'CustomActor'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and global actor 'CustomActor'-isolated uses}}
5353
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableLinkedList<Int>' into main actor-isolated context may introduce data races}}
5454

5555
let y = secondList.listHead!.next!
5656

5757
await transferToMainActor(y) // expected-tns-warning {{transferring 'y' may cause a race}}
58-
// expected-tns-note @-1 {{transferring global actor 'GlobalActor'-isolated 'y' to main actor-isolated callee could cause races between main actor-isolated and global actor 'GlobalActor'-isolated uses}}
58+
// expected-tns-note @-1 {{transferring global actor 'CustomActor'-isolated 'y' to main actor-isolated callee could cause races between main actor-isolated and global actor 'CustomActor'-isolated uses}}
5959
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableLinkedListNode<Int>' into main actor-isolated context may introduce data races}}
6060
}
6161

62-
@GlobalActor func useGlobalActor2() async {
62+
@CustomActor func useCustomActor2() async {
6363
var x = NonSendableLinkedListNode<Int>()
6464

6565
if booleanFlag {
6666
x = secondList.listHead!.next!
6767
}
6868

6969
await transferToMainActor(x) // expected-tns-warning {{transferring 'x' may cause a race}}
70-
// expected-tns-note @-1 {{transferring global actor 'GlobalActor'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and global actor 'GlobalActor'-isolated uses}}
70+
// expected-tns-note @-1 {{transferring global actor 'CustomActor'-isolated 'x' to main actor-isolated callee could cause races between main actor-isolated and global actor 'CustomActor'-isolated uses}}
7171
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableLinkedListNode<Int>' into main actor-isolated context may introduce data races}}
7272
}
7373

74-
@GlobalActor func useGlobalActor3() async {
74+
@CustomActor func useCustomActor3() async {
7575
var x = NonSendableLinkedListNode<Int>()
7676

7777
if booleanFlag {
7878
x = secondList.listHead!.next!
7979
}
8080

81-
await transferToGlobalActor(x)
81+
await transferToCustomActor(x)
8282
}
8383

84-
@GlobalActor func useGlobalActor4() async {
84+
@CustomActor func useCustomActor4() async {
8585
let x = NonSendableLinkedListNode<Int>()
8686

87-
await transferToGlobalActor(x)
87+
await transferToCustomActor(x)
8888

8989
useValue(x)
9090
}
9191

92-
@GlobalActor func useGlobalActor5() async {
92+
@CustomActor func useCustomActor5() async {
9393
let x = NonSendableLinkedListNode<Int>()
9494

9595
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}
96-
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'GlobalActor'-isolated uses}}
97-
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableLinkedListNode<Int>' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
96+
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'CustomActor'-isolated uses}}
97+
// expected-complete-warning @-2 {{passing argument of non-sendable type 'NonSendableLinkedListNode<Int>' outside of global actor 'CustomActor'-isolated context may introduce data races}}
9898

9999
useValue(x) // expected-tns-note {{use here could race}}
100100
}
@@ -104,49 +104,49 @@ private struct StructContainingValue { // expected-complete-note 2{{}}
104104
var y = SendableKlass()
105105
}
106106

107-
@GlobalActor func useGlobalActor6() async {
107+
@CustomActor func useCustomActor6() async {
108108
var x = StructContainingValue()
109109
x = StructContainingValue()
110110

111111
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}
112-
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'GlobalActor'-isolated uses}}
113-
// expected-complete-warning @-2 {{passing argument of non-sendable type 'StructContainingValue' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
112+
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'CustomActor'-isolated uses}}
113+
// expected-complete-warning @-2 {{passing argument of non-sendable type 'StructContainingValue' outside of global actor 'CustomActor'-isolated context may introduce data races}}
114114

115115
useValue(x) // expected-tns-note {{use here could race}}
116116
}
117117

118-
@GlobalActor func useGlobalActor7() async {
118+
@CustomActor func useCustomActor7() async {
119119
var x = StructContainingValue()
120120
x.x = firstList
121121

122122
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}
123-
// expected-tns-note @-1 {{transferring global actor 'GlobalActor'-isolated 'x' to nonisolated callee could cause races between nonisolated and global actor 'GlobalActor'-isolated uses}}
124-
// expected-complete-warning @-2 {{passing argument of non-sendable type 'StructContainingValue' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
123+
// expected-tns-note @-1 {{transferring global actor 'CustomActor'-isolated 'x' to nonisolated callee could cause races between nonisolated and global actor 'CustomActor'-isolated uses}}
124+
// expected-complete-warning @-2 {{passing argument of non-sendable type 'StructContainingValue' outside of global actor 'CustomActor'-isolated context may introduce data races}}
125125

126126
useValue(x)
127127
}
128128

129-
@GlobalActor func useGlobalActor8() async {
129+
@CustomActor func useCustomActor8() async {
130130
var x = (NonSendableLinkedList<Int>(), NonSendableLinkedList<Int>())
131131
x = (NonSendableLinkedList<Int>(), NonSendableLinkedList<Int>())
132132

133133
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}
134-
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'GlobalActor'-isolated uses}}
135-
// expected-complete-warning @-2 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
136-
// expected-complete-warning @-3 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
134+
// expected-tns-note @-1 {{transferring disconnected 'x' to nonisolated callee could cause races in between callee nonisolated and local global actor 'CustomActor'-isolated uses}}
135+
// expected-complete-warning @-2 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'CustomActor'-isolated context may introduce data races}}
136+
// expected-complete-warning @-3 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'CustomActor'-isolated context may introduce data races}}
137137

138138
useValue(x) // expected-tns-note {{use here could race}}
139139
}
140140

141-
@GlobalActor func useGlobalActor9() async {
141+
@CustomActor func useCustomActor9() async {
142142
var x = (NonSendableLinkedList<Int>(), NonSendableLinkedList<Int>())
143143

144144
x.1 = firstList
145145

146146
await transferToNonIsolated(x) // expected-tns-warning {{transferring 'x' may cause a race}}
147-
// expected-tns-note @-1 {{transferring global actor 'GlobalActor'-isolated 'x' to nonisolated callee could cause races between nonisolated and global actor 'GlobalActor'-isolated uses}}
148-
// expected-complete-warning @-2 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
149-
// expected-complete-warning @-3 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'GlobalActor'-isolated context may introduce data races}}
147+
// expected-tns-note @-1 {{transferring global actor 'CustomActor'-isolated 'x' to nonisolated callee could cause races between nonisolated and global actor 'CustomActor'-isolated uses}}
148+
// expected-complete-warning @-2 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'CustomActor'-isolated context may introduce data races}}
149+
// expected-complete-warning @-3 {{passing argument of non-sendable type '(NonSendableLinkedList<Int>, NonSendableLinkedList<Int>)' outside of global actor 'CustomActor'-isolated context may introduce data races}}
150150

151151
useValue(x)
152152
}

0 commit comments

Comments
 (0)